-->
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: How to specify the custom id generator class in annotation
PostPosted: Wed Oct 18, 2006 10:01 pm 
Newbie

Joined: Wed Oct 18, 2006 9:49 pm
Posts: 3
In XDOCLET, I could use the following syntax to specify the id generator class to be a customized class

[code]
@hibernate.id
* generator-class="com.***.MyPrimaryKeyGenerator" * column="ID" length="32"
[/code]

How can I do the same thing with annotation? thanks


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 19, 2006 5:42 am 
Newbie

Joined: Wed Oct 18, 2006 11:18 am
Posts: 9
Location: Nanterre, France
As far as I know, it is not possible with standard JPA annotations, as JPA only specify support for Table and Sequence based generators.

However, Hibernate Annotations offers the "org.hibernate.annotations.GenericGenerator" specific annotation that allow you to use a custom generator (via its "strategy" attribute) : see http://www.hibernate.org/hib_docs/annotations/reference/en/html_single/#entity-hibspec-identifier


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 19, 2006 5:44 am 
Newbie

Joined: Wed Oct 18, 2006 11:18 am
Posts: 9
Location: Nanterre, France
As far as I know, it is not possible with standard JPA annotations, as JPA only specifies support for Table and Sequence based generators.

However, Hibernate Annotations offer the "org.hibernate.annotations.GenericGenerator" specific annotation that allow you to use a custom generator (via its "strategy" attribute) : see http://www.hibernate.org/hib_docs/annotations/reference/en/html_single/#entity-hibspec-identifier


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 19, 2006 9:30 am 
Newbie

Joined: Wed Oct 18, 2006 9:49 pm
Posts: 3
Thanks, it brings me another question, how can I define a strategy to map with my custom id generator class. I didn't find it inhibernate reference.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 19, 2006 12:58 pm 
Newbie

Joined: Wed Oct 18, 2006 9:49 pm
Posts: 3
thanks, I got

strategy is the short name of an Hibernate3 generator strategy or the fully qualified class name of an IdentifierGenerator implementation. You can add some parameters through the parameters attribute


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.