aspose file tools
The moose likes Object Relational Mapping and the fly likes Hibernate Query Language Question (simple) Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Reply Bookmark "Hibernate Query Language Question (simple)" Watch "Hibernate Query Language Question (simple)" New topic
Author

Hibernate Query Language Question (simple)

Michael Jammy
Greenhorn

Joined: Sep 21, 2011
Posts: 11

Hi there,

I have a question, which should be easy to answer for any HQL pro. I execute the following code:

It queries the title column of the Product database, for my search query by the name of, "query". It works as it should. However, I want to use the same query to also check in p.productDesc.

I've tried many ways I can think of, including:

My other question is, how do I get it to also find part of the word. E.g. if my query is "hel", it also finds a row/column with "help me", or "where the hell did you go?". I tried "%", but it gives me errors everytime I add it.


Oracle Certified Java Programmer 6
Hebert Coelho
Ranch Hand

Joined: Jul 14, 2010
Posts: 754

q01) try this:

q02) "%hel" try something like this.


[uaiHebert.com] [Full WebApplication JSF EJB JPA JAAS with source code to download] One Table Per SubClass [Web/JSF]
Michael Jammy
Greenhorn

Joined: Sep 21, 2011
Posts: 11

Thank you for your response Hebert, however it did not work.

Here I querried for the word, "catisfactions" and the error was:


Also, adding % to my method as such:


causes the following error:
Hebert Coelho
Ranch Hand

Joined: Jul 14, 2010
Posts: 754

At the way I putted to you, you will need to set up your parameter two times. [=
Michael Jammy
Greenhorn

Joined: Sep 21, 2011
Posts: 11

Hebert Coelho wrote:At the way I putted to you, you will need to set up your parameter two times. [=


Thank you for your aid, I solved it as follows:

Also removed the lower() from ? because like ignores case.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Hibernate Query Language Question (simple)
 
Similar Threads
Help with HQL statement
ejb3unit-1.2 SessionBean Test
Hibernate Wildcard Query
Using user_source
Matching words except those in tags with regex