0

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 
1

1 Answer 1

1

Provide result transformer Criteria.DISTINCT_ROOT_ENTITY in query

List depart= sess.createQuery("From Department", Department.class).setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY).getResultList(); 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.