Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JPQL does TRIM column containing only blank spaces returns null?

plsql noviceOct 6 2014 — edited Nov 6 2014

Hi all,

In Oracle SQL, when you do trim(column_name), if column_name is blank spaces only (say datatype is CHAR(8)), then "trim(column_name) is null" is true.

In JPQL, if you do "TRIM ( BOTH FROM p.column_name ) is null", does it evaluate to true just like in Oracle SQL?

The reason I'm asking, is my colleague wrote some code in JPQL like below:

... TRIM ( BOTH FROM CONCAT(p.column_name, '#@') ) = '#@'

He said he originally wanted to compare the TRIM result to empty String '', but the result is false, so he concat the column to some junk.

So if after the TRIM, the result is the same junk he added, then the column contains only blanks.

I think this works but there could a simpler way to do it. Hence my question above.

Many thanks,

Will.

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 4 2014
Added on Oct 6 2014
1 comment
1,992 views