Joined: Wed May 28, 2008 3:56 pm Posts: 18
|
public class JCMSYearIndicator @OneToMany public List<DepartmentMonths> departmentMonths ;
I would like to get the parent record with one child record from this @OneToMany mapping so I have used the following query [code]query = sessionFactory.getCurrentSession().createQuery( "from YearDepartment yearDepartment join yearDepartment.departmentMonths m WHERE m.id=?"); query.setInteger(0, 1234); temp = query.list();[/code]
This returns a list of objects and each position has two objects - an object of yearDepartment & departmentMonths.
Since I require a list of yearDepartments I iterate through this list with two objects and make it a list of yearDepartment with a single departmentMonths embedded inside.
[b]Is there a way to get yearDepartment with just one departmentMonths inside the parent entity using the query/criterion/formula or any other means rather than manually processing it ?[/b]
|
|