-->
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.  [ 5 posts ] 
Author Message
 Post subject: Hibernate mapping option proposal
PostPosted: Fri Apr 02, 2004 2:39 am 
Newbie

Joined: Fri Apr 02, 2004 2:34 am
Posts: 8
Location: Germany
Hi All
I guess it's quite often to store child Sets or Bags of parent entity in the distinct database table. So, I like Hibernate because its really that I need :) so I can get size of the array without initialization of that array. But if Hibernate provides me with feathre to map a field of the object to SQL formula, so I can map a property Parent#childrensCount to "select count(*) from CHILDREN where PARENT_ID={id}" it would be nice either.

_________________
Br.
Renat


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 02, 2004 3:24 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
This is possible!


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 03, 2004 3:59 am 
Newbie

Joined: Fri Apr 02, 2004 2:34 am
Posts: 8
Location: Germany
Yes, but it require me to write a filter execution inside getChildrenCount method, but I'm talking about how nice it could be if it were already done by Hibernate, so the field childrenCount mapped not to database column but to query. Or I missed something in the docs?

_________________
Br.
Renat


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 03, 2004 4:29 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
http://forum.hibernate.org/viewtopic.php?t=929568

it may help


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 03, 2004 8:39 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Exactly.

Code:
<property name="childCount"
    type="integer"
    formula="( select count(*) from Child c where c.parent = id )"/>


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.