-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Getting a single entity from a query
PostPosted: Thu Oct 21, 2010 1:16 am 
Newbie

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]


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.