Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Object Relational Mapping
Search Coderanch
Advance search
Google search
Register / Login
Win a copy of
OCP Oracle Certified Professional Java SE 21 Developer Study Guide: Exam 1Z0-830
this week in the
Programmer Certification
forum!
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Tim Cooke
Liutauras Vilda
Jeanne Boyarsky
paul wheaton
Sheriffs:
Ron McLeod
Devaka Cooray
Henry Wong
Saloon Keepers:
Tim Holloway
Stephan van Hulst
Carey Brown
Tim Moores
Mikalai Zaikin
Bartenders:
Frits Walraven
Forum:
Object Relational Mapping
How to apply case insestive on the Hibernate Query?
Rd Dari
Ranch Hand
Posts: 214
I like...
posted 10 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi All,
below is the code using Like operator using hibernate. Can any one tell me how to apply case Insesitive on the below query.
@Override public List<LAHSGroupStudyMstr> getLikeSearchRecordsForGroup(BigDecimal siteId, BigDecimal customerId, String search)throws DAOException{ List<LAHSGroupStudyMstr> likeSearchList = null; try{ likeSearchList = session.createQuery("select id.groupSeqId, groupName, groupDesc, status from LAHSGroupStudyMstr where id.siteId=:siteId and customerId=:customerId and groupName LIKE :groupName" + " OR groupDesc Like :groupDesc ") .setBigDecimal("customerId", customerId) .setBigDecimal("siteId", siteId) .setString("groupName", "%"+search+"%") .setString("groupDesc", "%"+search+"%").list(); } catch(DAOException e){ throw e; } return likeSearchList; }
Thanks in advanced!
chets patel
Ranch Hand
Posts: 77
I like...
posted 10 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Use upper function of sql which convert into upper case. And while passing parameter to query, convert all variables into upper case.
@Override public List<LAHSGroupStudyMstr> getLikeSearchRecordsForGroup(BigDecimal siteId, BigDecimal customerId, String search)throws DAOException{ List<LAHSGroupStudyMstr> likeSearchList = null; try{ likeSearchList = session.createQuery("select id.groupSeqId, groupName, groupDesc, status from LAHSGroupStudyMstr where id.siteId=:siteId and customerId=:customerId and UPPER(groupName) LIKE :groupName" + " OR UPPER(groupDesc) Like :groupDesc ") .setBigDecimal("customerId", customerId) .setBigDecimal("siteId", siteId) .setString("groupName", "%"+search.toUpperCase()+"%") .setString("groupDesc", "%"+search.toUpperCase()+"%").list(); } catch(DAOException e){ throw e; } return likeSearchList; }
For more reading on hibernate, read my blogpost
http://morejava4u.blogspot.com/p/hibernate.html
Drove my Chevy to the levee but the levee was dry. A wrung this tiny ad and it was still dry.
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
What is the need for creating a Exception for DAO Layer
Hibernate Search using Criteria with OR condition.
[Newb] How to reuse attributes
Pagination with Hibernate and SP
Hibernate with SP
More...