-->
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: Using autoincrement generator for key in composite-id
PostPosted: Wed Feb 17, 2010 7:44 am 
Newbie

Joined: Mon Feb 08, 2010 5:48 pm
Posts: 3
Please can someone help me with creating auto-increment generator for key property in composite-id.
There is a parent child relationship, and in Child table one key is taken from parent table, but childID should be generated automatically.

Code:
<class name="Child">
      <composite-id>
         <key-many-to-one name="parent" class="Parent" lazy="false">
            <column name="ParentID"></column>
         </key-many-to-one>
         <key-property name="childID" column="ChildID" type="long"/>   
      </composite-id>
      
      <property name="someField" column="SomeField" type="string" />
   </class>


Top
 Profile  
 
 Post subject: Re: Using autoincrement generator for key in composite-id
PostPosted: Wed Feb 17, 2010 7:59 am 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
Composite keys must always be assigned by the application. See http://docs.jboss.org/hibernate/stable/ ... ompositeid


Top
 Profile  
 
 Post subject: Re: Using autoincrement generator for key in composite-id
PostPosted: Wed Feb 17, 2010 9:34 am 
Newbie

Joined: Mon Feb 08, 2010 5:48 pm
Posts: 3
Thank you,
I'll do it from the application!


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.