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

HQL join problem

 
Prasath Premkumar
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic