-->
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: Id generation
PostPosted: Mon Feb 22, 2010 3:05 pm 
Newbie

Joined: Mon Feb 22, 2010 2:07 pm
Posts: 8
Hello.

I faced with some trouble in primary key generation.
What I want to do is to make IDs to be a power of two: 2, (2*2), (2*2*2), ... (2*2*n-times*2)
I was failed to find a reference in the documentation. Is there any way to specify my own generator for the object ID? Can anyone, please, point me to an appropriate part of the documentation. Also it would be be great to have some example. Thanks.
I'm using hibernate + mySql.


Top
 Profile  
 
 Post subject: Re: Id generation
PostPosted: Mon Feb 22, 2010 6:15 pm 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
You'll need to create a class that implements the org.hibernate.id.IdentifierGenerator interface and specify that class in the mapping files. See http://docs.jboss.org/hibernate/stable/ ... aration-id for more information.


Top
 Profile  
 
 Post subject: Re: Id generation
PostPosted: Tue Feb 23, 2010 4:55 pm 
Newbie

Joined: Mon Feb 22, 2010 2:07 pm
Posts: 8
Thank you much for your reply. It was not so hard after your help. I got the appropriate result


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.