-->
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: Custom Id Generator
PostPosted: Thu Mar 23, 2006 4:47 am 
Beginner
Beginner

Joined: Mon Dec 05, 2005 4:15 am
Posts: 36
There is a @org.hibernate.annotations.GenericGenerator annotation which allows to define my own ID Generator strategy. But this is not a part of standard EJB3 Annotations (JSR-220), but a Hibernate specific extension. How can I define my ID Generator with standard EJB3 Annotations?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 23, 2006 8:28 am 
Expert
Expert

Joined: Sat Oct 25, 2003 8:49 am
Posts: 490
Location: Vrhnika, Slovenia
# A number of annotations have been tweaked in the spec here and there. refer to the EJB3 spec for more details.

* For instance: @Id(generator=GeneratorType) is now two annotations @Id and @GeneratedValue


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 23, 2006 9:37 am 
Beginner
Beginner

Joined: Mon Dec 05, 2005 4:15 am
Posts: 36
alesj wrote:
# A number of annotations have been tweaked in the spec here and there. refer to the EJB3 spec for more details.

* For instance: @Id(generator=GeneratorType) is now two annotations @Id and @GeneratedValue


I read the spec but I don't found how to do this.
I have an @Id annotation.
I have a @GeneratedValue(generator="name") annotation that declares that I apply the generator named "name" to get the value for my ID.

I need also an annotation for my generator which describes how I get the value for generator "name". It cound be @SequenceGenerator, @TableGenerator or Hibernate-specific @GenericGenerator. My question - how I can make my own generator, another that one of these 3 generators? With @GenericGenerator it is very easy - I say @GenericGenerator(name="name", strategy="mypackage.Myclass") and write the mypackage.Myclass class that implements the interface IdentifierGenerator.

Thanx.


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.