[英]Hibernate join fetch
I have implemented the following example in this blog https://www.tutorialandexample.com/hibernate-n-1-select-problem/ but I am not happy with the output that I am getting.我在此博客https://www.tutorialandexample.com/hibernate-n-1-select-problem/ 中实现了以下示例,但我对得到的输出不满意。 I am displaying the output which shows Department details and Employee details printed as twice .
我显示的输出显示部门详细信息和员工详细信息打印为两次。 I want to get the Department details and Employee details to be displayed only once .
我想让部门详细信息和员工详细信息只显示一次。 Any Suggestions ?
有什么建议 ?
The size of depart List object is 4 but actually it must be 2 .离开列表对象的大小是 4 但实际上它必须是 2 。
output :输出 :
Department details:::::
20 IT
Employees details::::::
21 jyotika
22 shubham
Department details:::::
20 IT
Employees details::::::
21 jyotika
22 shubham
Department details:::::
23 Accounts
Employees details::::::
24 nihal
25 neha
Department details:::::
23 Accounts
Employees details::::::
24 nihal
25 neha
在查询中提供结果转换器Criteria.DISTINCT_ROOT_ENTITY
List depart= sess.createQuery("From Department", Department.class).setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY).getResultList();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.