This week's book giveaway is in the
We're giving away four copies of
and have Sam Newman on-line!
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
this week in the
Object Relational Mapping
Result of HQL for associated objects
Joined: Jul 19, 2011
Jul 19, 2011 02:51:54
I am having 3 tables:
USER, ADDRESS, ADDRESSSET
in an oracle database.
The structure of these 3 tables are as follows:
USERID [FOREIGN_KEY FROM USER]
ADDRESSID [FOREIGN_KEY FROM ADDRESS]
ADDRESSTYPE [Example: HOME, OFFICE, SHIPPING]
ADDRESSSET table behaves as link table. It has been designed this way to share addresses among different users.
I have created hibernate mapping files and POJOs for these 3 tables.
Now, I need to write a method where input parameter will be List<Long> userIdList.
And, return type must be List<User> where User has his address details i.e. his office, home & shipping address.
I have written an HQL:
from User user
left outer join user.profileaddresssets as uas
left outer join uas.address add
where user.userid in (:userIdList)
But, the result of this HQL is a List<Object[ ]> instead of List<User>.
Is it possible to get List<User>? If yes, then, How?
Thanks & Regards,
I agree. Here's the link:
subject: Result of HQL for associated objects
outer join in HQL
How many tables can a join have max ?
Hibernate, User and Address with association table between
Regarding Hibernate Query
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015