Hibernate Queries - II
2 May 2008In this post, I will continue presenting HQL tips and trick that will help you in development.
The following query may return multiple objects as an array of type Object[].
select mother, offspr, mate.name from DomesticCat as mother inner join mother.mate as mate left outer join mother.kittens as offspr
Now suppose, you would like to get a list in theabove scnario - use the following query:
select new list(mother, offspr, mate.name) from DomesticCat as mother inner join mother.mate as mate left outer join mother.kittens as offspr
One may need type safe Java object as result.
select new Family(mother, mate, offspr) from DomesticCat as mother join mother.mate as mate left join mother.kittens as offspr
This is the beauty of Hibernate. You can get data fetched from database tables in form of list, objects or arrays. This is useful in complex applications.
Do read the next posts on this very topic.
Related Posts:
Top Of Page | Trackback
If you found this page useful, consider linking to it. Simply copy and paste the code below into your web site.
It will look like this: Hibernate Queries - II