File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes HQL join problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "HQL join problem" Watch "HQL join problem" New topic
Author

HQL join problem

Prasath Premkumar
Ranch Hand

Joined: Nov 13, 2008
Posts: 43

Hi all,

I have a table named doc_type and another one named release. In doc_type.hbm.xml i have defined a many-to-one mapping for release like this:


note that DocType can be without release too.

I wrote a HQL like this for a scenario where i needed to get all the doctypes (with or without release) for a common name ordered by release.releaseOrder and issueDate.



But it didnt return DocTypes which dont have release. But when i removed from the order by clause, it returned all the doctypes with or without release object. (which is the expected behavior). So i found out that since i'm using an attribute of the Release object in HQL, when Release is null in DocType, it is not returning that record.

So i thought i can to a left join and wrote a HQL like this:



which returned everything but instead of returning a List, it resulted in List<List> something like that....

What is the possible HQL for this scenario???

Thanks in advance.
Prasath Premkumar
Ranch Hand

Joined: Nov 13, 2008
Posts: 43
Hi,

I was able to fix that issue. Thanks anyway.

If anyone wants to know what i did:



This HQL does what i needed.

Thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: HQL join problem
 
Similar Threads
So much on the Left Joins in Hibernate
left join fetch returns duplicates
Complex HQL query conversion (from SQL)
LEFt OUTER JOIN returning extraneous results...
Question on query - select one row with max value in one field