Kumar-Sandeep
Kumar-Sandeep

Reputation: 222

restrictions Not equal criteria default behaviour

I experiment and found that restrictions not equals default nature is ignore case.Please tell me if i m wrong. I m using hibernate 3.x.

For example:-

add(Restrictions.ne("channelCode","JAVA"));

add(Restrictions.ne("channelCode", "JAVA").ignorecase())

giving me same behaviour for all strings like jAVa, java,JAva etc

Upvotes: 0

Views: 987

Answers (3)

Kumar-Sandeep
Kumar-Sandeep

Reputation: 222

I have solved the issue, actually mysql search(select) queries are case insenstive by default.

Thanks for your feed back.

Upvotes: 1

Learner
Learner

Reputation: 21393

When you add ignorecase() then hibernate tries to convert the value to lower case and do the comparision like this:

lower(this_.channelCode)<>'JAVA'

So this should work without any issues.

Upvotes: 0

Killer
Killer

Reputation: 590

try this,

  add(Restrictions.ilike("channelCode", "JAVA%"));

Upvotes: 0

Related Questions