• Post Reply Bookmark Topic Watch Topic
  • New Topic

Hibernate query using named parameter and %

 
Ricardo Estafan
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am having some difficulties creating a hibernate query using both named parameters and the %.

For instance when i search for a certain product using a named query and named parameters it looks like this :

<query name="searchProducts">
<![CDATA[from Product where amount != 0 and namelike %:searchText% or title like %:searchText%]]>
</query>

I can't get it to work.

Can anybody help me out?

Thank you.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65679
129
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe that you would need to use the wildcards in the bind data, not in the query itself.
 
my overalls have superpowers - they repel people who think fashion is important. Tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!