Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate Wildcard Query

 
Bai Shen
Ranch Hand
Posts: 323
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a column that I need to do a wildcard query on. For example, if I put in "bob", I should get back "jim bob", "joe bob", and "bobbie". However, I can't seem to get the query to work. I tried just adding % to the front and back of the variable, but then Hibernate gives me an unexpected char error.

Also, is there a list of unallowed characters in the queries? I tried a query with a _ in it, and it didn't work until I surrounded it with '.

 
Sridhar Santhanakrishnan
Ranch Hand
Posts: 317
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



Try this.
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use Criteria and Restrictions APIĀ“s.

http://www.hibernate.org/hib_docs/v3/api/org/hibernate/Criteria.html
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic