-->
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.  [ 1 post ] 
Author Message
 Post subject: Is it possible to over-ride a classes generated ID?
PostPosted: Thu Nov 29, 2007 4:24 pm 
Newbie

Joined: Thu Nov 29, 2007 3:44 pm
Posts: 1
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.2

Mapping documents:
<hibernate-mapping>
<class name="example.MyClass" table="my_table">
<id name="id" column="ID" type="long" unsaved-value="0">
<generator class="identity"/>
</id>
</class>
</hibernate-mapping>

I'm trying to persist the class in 2 databases, in one, I need to use the identity to populate the ID. In the second database, I'm trying to assign the object it's ID first, so for the first database, everything works great

Currently, if I do the following in the second database:
MyClass myObject=new MyClass();
myObject.setId(100);
session.save(myObject);

The Id of 100 will be overwritten with the identity value.

Is there any way to over-ride the fact that the mapping file said to use an identity?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.