-->
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: Using one sequence per table
PostPosted: Sun Aug 15, 2004 9:27 pm 
Beginner
Beginner

Joined: Wed Aug 04, 2004 9:01 pm
Posts: 21
I had created a HIBERNATE_SEQUENCE in oracle that is being used by 5 tables. The counter is not reset to the value in the table but it looks like the sequence is acting global. Is there a way that I could use one sequence generation per table?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 16, 2004 1:37 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
why don't you just creat one sequence per table?
Hibernate_seq1, hibernate_seq2 ...

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 16, 2004 3:49 am 
Senior
Senior

Joined: Fri Nov 21, 2003 5:55 am
Posts: 155
The rules in Oracle are 1 sequence per table because if you drop a table and populate it after you can have a hole in your sequence of several values.
So for the references tables use an unique specific key and for data tables use one seuqence for each and with hibernate reference them in your mapping files.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 16, 2004 3:51 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Why should I care about a "hole in my sequence of values"? They are surrogate keys, they don't have any meaning.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 16, 2004 4:10 am 
Senior
Senior

Joined: Fri Nov 21, 2003 5:55 am
Posts: 155
My "hole" :+) is only to define that if you drop a table you loose the value between x and y and if you are using one unique sequence for all your schema you re not able to use these after.
A hole in sequence is not important but it's not very clean in database development.

For example table Person 1 to 5000 and Product 5000 to 10000, if you drop Person the next value of your sequence will be 10001 and you have a "hole" of none used value 1 to 5000.

It's only a method for Oracle and the way one sequence for a schema is not a good thing. Nothing in relation with Hibernate.

Christian have you seen my post about sequence and strange value? because it's a big problem and I don't understand why. I think it comes from Oracle 8 but I m not sure.

For Adaniz, you can use this, and create some sequences and reference them in your mapping files.
<id name="id"
type="java.lang.Integer"
column="ID">
<generator class="sequence">
<param name="sequence">WTOLD.SEQ</param>
</generator>
</id>


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.