This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes HQL help needed Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "HQL help needed" Watch "HQL help needed" New topic
Author

HQL help needed

Venkata Kumar
Ranch Hand

Joined: Apr 16, 2008
Posts: 110

Hi All,

I have two objects Person, Manager and the objects are mapped to database tables Person and Manager. I want to get all the persons having no manager at all or having manager whose name is "xyz".

SQL query to get the desired result is

I want to get the same result using HQL query and tried the following HQL query. But it is not giving expected results.


Any help on HQL query is appreciated.

Thanks,
Venkat




SCJP 5.0, SCWCD 5, preparing for SCDJWS
Arun Kumarr
Ranch Hand

Joined: May 16, 2005
Posts: 513

Use joins.
Hibernate support for unions is selective.
If you're still uncomfortable and have a complex query, user result set transformer AliasToEntity Mapping and map your query results into your pojo.
But, in this case, I would suggest you to use a simple join.


If you are not laughing at yourself, then you just didn't get the joke.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: HQL help needed
 
Similar Threads
"New to Hibernate" Question - How to fetch only a few fields
Hibernate Newbie
persist() null pointer exception
hibernate best start sample
How to insert DateTime with HQL