我有3个表。法师,child1,的child2。从多个表中获取休眠数据
大师与child1有一对多的关系。
大师与child2有一对多的关系。
child1和child2之间没有关系。
我想从使用休眠的单个查询中的所有3个表中检索数据。
Table - Master
id
11
12
Table - child1
id deposited_date Master_child1_reltion_key
2 2012-10-10 11
3 2012-10-10 11
4 2012-10-10 11
5 2011-01-01 12
6 2005-02-20 13
Table - child2
id phoneNo phone_type master_child2_relation_key
15 1111111 personal 11
16 2222222 office 11
17 3333333 home 11
18 1010100 personal 12
在表child2中,对主表可以有无,1,2或3条记录。
我想检索所有3个表中的值。像
id deposited_date phoneno1 phoneno2 phoneno3
11 2012-10-10 1111111 2222222 3333333
12 2011-01-01 1010100
13 2005-02-20
是否有可能在hibernate中使用单个查询检索数据还是需要使用多个查询?
任何人都可以帮忙吗? – user1607139 2012-08-17 16:48:55
如果你可以为此写一个sql,那么你也可以写一个hql – Swapnil 2012-08-18 06:18:27