-->
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: ID GENERATOR THREAD SAFE WITH ORACLE 9
PostPosted: Sun Oct 29, 2006 6:32 am 
Newbie

Joined: Wed Oct 04, 2006 2:57 am
Posts: 4
Hello,
I'have a problem.
I have read online that id generator increment is not thread safe.
For this i have some problem in my servlet based application.
Sometimes i have exception for duplicate id if two thread work.
I use Oracle...for kill any problem what id generator i can use that work very well with oracle?
Native?Sequence?
Help me.
Thank you.
N.B.:Sorry for my english.

CIAO A TUTTI!


Top
 Profile  
 
 Post subject: Re: ID GENERATOR THREAD SAFE WITH ORACLE 9
PostPosted: Sun Oct 29, 2006 4:06 pm 
Beginner
Beginner

Joined: Tue Sep 26, 2006 11:46 pm
Posts: 33
I'd recommend the hilo generator

http://hibernate.org/hib_docs/reference ... on-id-hilo

it's thread and cluster safe while being fast and database independent


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 29, 2006 11:36 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Use a sequence or if you want some database independence use native (which equals sequence in Oracle).


Top
 Profile  
 
 Post subject: Re: ID GENERATOR THREAD SAFE WITH ORACLE 9
PostPosted: Mon Oct 30, 2006 6:07 am 
Newbie

Joined: Wed Oct 04, 2006 2:57 am
Posts: 4
EdC wrote:
I'd recommend the hilo generator

http://hibernate.org/hib_docs/reference ... on-id-hilo

it's thread and cluster safe while being fast and database independent



I read...

<generator class="net.sf.hibernate.id.TableHiLoGenerator">
<param name="table">uid_table</param>
<param name="column">next_hi_value_column</param>
</generator>

I must ubsert one table for each entity?

Or 1 tabel for all entity?

thank's!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 30, 2006 3:24 pm 
Beginner
Beginner

Joined: Tue Sep 26, 2006 11:46 pm
Posts: 33
You can use a different table for each object if you want, but it's not required.

If you use the same table the ID's will be unique across all types (which can be useful in itself.

You can actually just do the following and let hibernate default the table and column names.

Code:
<generator class="hilo"/>


If you do want the id's to be generated separately for each type, you can either use hilo configured with a different table for each type, or the MultipleHiLoPerTableGenerator:

http://www.hibernate.org/hib_docs/v3/ap ... rator.html

You also have the option of the Sequence HiLo Generator. This works like a hilo but uses a Sequence to get the hi bits rather than a table holding the next id.
http://www.hibernate.org/hib_docs/v3/ap ... rator.html



As for using the sequence generator. I know in hibernate 2 it was badly implemented which resulted in a serious performance hit. I haven't checked if this has been fixed in hibernate 3.


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.