-->
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.  [ 2 posts ] 
Author Message
 Post subject: Multiple mappings using the same ID generator
PostPosted: Fri Nov 21, 2003 7:22 pm 
Beginner
Beginner

Joined: Tue Nov 18, 2003 12:34 am
Posts: 39
Location: Dallas, Texas, US
Hello,
Suppose, I have two hibernate mappings such as the following with different name but using same ID generator:

------------- mapping 1 ------------------------------
<id
name="id"
column="StudentsHighschool_Id"
type="int"
unsaved-value="any"
>
<generator class="hilo">
<param name="table">IDGenerator</param>
<param name="column">nextval</param>
</generator>
</id>

------------- mapping 2 ------------------------------
<id
name="id"
column="StudentsCollege_Id"
type="int"
unsaved-value="any"
>
<generator class="hilo">
<param name="table">IDGenerator</param>
<param name="column">nextval</param>
</generator>
</id>

My questions are:
1. Will Hibernate use one generator table or will it have a generator table for each object?
2. If there will be only one generator, how will Hibernate determine the initial value for both objects?

Thanks in advance,
Madhan.


Top
 Profile  
 
 Post subject: Re: Multiple mappings using the same ID generator
PostPosted: Fri Nov 21, 2003 8:19 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
trmm333 wrote:
1. Will Hibernate use one generator table or will it have a generator table for each object?
2. If there will be only one generator, how will Hibernate determine the initial value for both objects?

Thanks in advance,
Madhan.


1. One table since you give it one table.
2. only the high value of hilo is persisted to db, so the first object will start with eg 100(lowpart) (100001) and the second 101(lowpart) 101001[/b]

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.