-->
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 generator id
PostPosted: Sun Aug 31, 2003 7:27 am 
Newbie

Joined: Thu Aug 28, 2003 11:19 pm
Posts: 17
i custom a primary key id, it's data type is int .

i need it automatically increase when new data is inserted


which generator in hibernate i should choose? increment/identity/sequence/hilo....... . i try every one ,either throw errors or can't increase


help me


Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 31, 2003 12:33 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
All the options are descrobed at http://www.hibernate.org/hib_docs/reference/html_single/#or-mapping-s1-4.

Are you looking for a simple in-memory generation strategy, or globally-unique generation? If the second, what type of database are you using?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 31, 2003 1:16 pm 
Newbie

Joined: Thu Aug 28, 2003 11:19 pm
Posts: 17
my database type is mysql

can you explain what is in-memory generation strategy and globally-unique generation and how do i resolve



i saw the document ,but can't accurately make a choose between all of the generator . can you explain it for me in detail ?


thanks you very much


Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 31, 2003 9:50 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
In memory means just that. The id generation strategy use some process within that JVM to determine a unique id; although, here the id is only unique to the given JVM. So if you have some sort of clustered environment, or two seperate apps using hibernate on the same same database there is the possibility of duplicating ids.

Global id generation generally depend on the DB for help in ensuring more strict uniqueness. MySQL supports identity columns, and so this would be the choice for this type of strategy of MySQL.

You mentioned you had tried identity. What was the problem you had with that?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 01, 2003 3:17 am 
Newbie

Joined: Thu Aug 28, 2003 11:19 pm
Posts: 17
yes it is ok! thanks


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.