-->
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.  [ 2 posts ] 
Author Message
 Post subject: Multiple @TableGenerator or @SequenceGenerator
PostPosted: Wed Sep 19, 2007 12:24 pm 
Beginner
Beginner

Joined: Fri Jul 28, 2006 12:01 pm
Posts: 21
Hibernate version: 3.2.3

Is there any way to reference multiple @TableGenerator annotations in an entity?

I have a use case where I am using one table to generator primary key values for all my entities. For two entities, I wish to to generate a business key (serial number). The number is not really important but I don't want it to grow as fast as it would if I used the primary key generator.

I am using @TableGenerator in testing with HSQLDB but will switch to @SequenceGenerator when I move to production (Oracle).

If this is not possible, is there some other way I can generate business keys that increment? (Gaps in the numbers are not really important)

Or if possible generate unique random numbers?

Ultimately the business key will be something like mm-dd-yyyy-xxxx or aaa-xxxx where xxxx is the number generated and prefixed either with a date string or with some alpha numeric value like a department number.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 01, 2007 9:34 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I don't really understand all you question. but wrt to your business key generation, you can write an IdentityGenerator implementation, and use @GenericGenerator

_________________
Emmanuel


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