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.  [ 3 posts ] 
Author Message
 Post subject: Number of childs?
PostPosted: Mon Jan 23, 2006 10:33 am 
Newbie

Joined: Mon Jan 23, 2006 9:21 am
Posts: 1
We have parents with childs (one-to-many) and we want to load parents with lazy childs. In the same step we want to know the number of childs of every parent.

Because we want show the user only the existing of childs but don't want to load this childs with join.

How is this task possible in HQL or Criteria Query? And should I extend my objects and xml mappings?

Best regards
Amin K.

Hibernate version: 3
SQL Server and Oracle


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 23, 2006 12:01 pm 
Expert
Expert

Joined: Fri Aug 19, 2005 2:11 pm
Posts: 628
Location: Cincinnati
if I were you, I'd create a named sql query, and extend the POJO for that class and add a method to call aforementioned named sql query upon object creation.

_________________
Chris

If you were at work doing this voluntarily, imagine what you'd want to see to answer a question.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 23, 2006 11:27 pm 
Regular
Regular

Joined: Tue Dec 14, 2004 5:21 am
Posts: 104
Location: india
You can count the number of query results without actually returning them:
( (Integer) session.iterate("select count(*) from ....").next() ).intValue()

reply if this helped :)

_________________
sHeRiN
thanks for your ratings ...... :)


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

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.