-->
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: Generate a unique identifier
PostPosted: Thu Feb 19, 2004 9:57 am 
Newbie

Joined: Thu Oct 02, 2003 2:02 pm
Posts: 4
I need to generate unique identifiers programmatically. They aren't supposed to be primary keys they simply must be unique within the scope of the database. I am planning on storing them in a long value and using them as customer reference numbers. I cannot and do not want to use primary keys for that purpose because the reference numbers have a business meaning and they may be repeated in some of the tables.

How do I use the Hibernate API to generate myself a unique id, preferably using a method native to the underlying database? Thanks for your answer and apologies if it's already covered somwhere. A search that I did on the site showed no useful results


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 19, 2004 11:53 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
You can generate ids on multiple ways: http://www.hibernate.org/hib_docs/reference/html/or-mapping.html#or-mapping-s1-4--generator

You can not map propertys that are generated by Hibernate, you need to do that manually.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 19, 2004 12:31 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Do it yourself (session.connection()) and have a look at the n.s.h.id pachake sources.

_________________
Emmanuel


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.