-->
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: Obtaining object collection fields directly using HQL query?
PostPosted: Wed Mar 12, 2008 1:17 am 
Regular
Regular

Joined: Tue Feb 19, 2008 6:05 pm
Posts: 82
In the following HQL query,

Quote:
select new someNewObj(AliasObjTableA.Field1, AliasObjTableB.Field2, AliasObjOfTableC.Field3,
AliasObjTabA.ChildObjSet) from TableA AliasObjTableA, TableB AliasObjTableB...
where ...
;

Query q = session.createQuery(query);


the someNewObj has fields and data types correctly defined and has a constructor with including fields such as a set of child Objects "childObjSet" as is used in the constructor above. Assuming that the TableA has a set of child Objects correctly mapped in the mapping file as:

Quote:
<set name="childObjSet"
inverse="true"
lazy="false"
cascade="all">
<key column="TableAPrimaryKey"/>
<one-to-many class="TableB"/>
</set>



I get a cannot execute query exception.

Isn't there a way to write queries to get sets of child objects as above?? What is the correct way then if there are so many sets of child objects to be read for a give parent object?

-Regards
Rama


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.