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. 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 .
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();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.