Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

String Equality diffs bw EJB-QL and SQL

 
Alex Sharkoff
Ranch Hand
Posts: 209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

Spec (section 11.2.10) says that:

That comparison of strings should not be affected by their representation in the persistent store (eg, with regard to padding etc.). Two strings are equal if and only if they contain the same sequence of characters. This is different to SQL.


My question is: how is it different to SQL?
Does it mean that the following EJB-QL

select object(e)
from EmployeeSchema e
where e.firstName = 'John'


will return all employees with the first name of John even those that contain blank spaces (eg, employees with first name ' John ' will be selected)

while the following SQL

select *
from EmployeeTable
where FirstName = 'John'

will not select employees whose first names are not exactly John (eg, employees with ' John ' as the first name will not be selected)


Thanks to all in advance.
 
Nathaniel Stoddard
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It looks like you understand this. I've never run across the implications of this ... and I imagine that some containers just ignore it ... but yeah.
 
Alex Sharkoff
Ranch Hand
Posts: 209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Nathaniel

I guess I should try this scenario on my app server (jboss) and see what happens. I get around it I'll let you know about the results.


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic