-->
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: Native Generator Question
PostPosted: Thu Dec 18, 2003 5:35 pm 
Newbie

Joined: Mon Nov 17, 2003 7:53 pm
Posts: 15
I am using native generator to generate my primary key id for two of my objects. The id mapping of both of my objects look like this (note that the classes are mapped to two different tables):

<id name="id" column="id" type="long">
<generator class="native"/>
</id>

Now the problem is that when I create an object of each class and save it to the DB using the session.save() method. The first objects that is saved gets an id of 1 and the second object gets 2. Shouldn't both get an id of 1 since they are in a different table?

Note that I am using Oracle and that I start with clean tables with no entries.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 18, 2003 7:25 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
No, the generator creates a unique id for every object you ever save


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 19, 2003 4:47 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
The native generator for Oracle is a single sequence so your result is correct. You can define an argument against native generator to select the sequence to use. Have a look at the docs for sequence id generator.


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.