-->
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.  [ 8 posts ] 
Author Message
 Post subject: update id
PostPosted: Mon Dec 27, 2004 9:13 am 
Beginner
Beginner

Joined: Sat Oct 04, 2003 7:00 am
Posts: 26
Location: Roma,IT
Hibernate version: 2.7c

Name and version of the database you are using: Sybase Anywere 9.02

It's possible to update id of a persistent object:

session s;

...

// do this line update the id?
s.upadate(bean, newId);

...


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 27, 2004 9:47 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
No

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 27, 2004 10:40 am 
Beginner
Beginner

Joined: Sat Oct 04, 2003 7:00 am
Posts: 26
Location: Roma,IT
tnx


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 27, 2004 10:43 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
what you can do is delete the "old" object, create a new one with the new id (should be assigned id) and have a deep copy.

Anyway it isn't a solution, id cannot, by nature, be updated.

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


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 27, 2004 10:57 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
That's why id must not be a natural key. Go DBAs go!

_________________
Emmanuel


Top
 Profile  
 
 Post subject: Is there a simple api to do deep copy in hibernate3 yet?
PostPosted: Mon Mar 28, 2005 2:22 pm 
Regular
Regular

Joined: Thu Sep 09, 2004 6:46 pm
Posts: 96
Is there a simple api to do deep copy in hibernate3 yet?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 28, 2005 2:24 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Sure. SessionFactory.getClassMetadata().

It is trivial to implement whatever you think deepCopy() should do. (Everyone has a different definition of deepCopy(), of course.)


Top
 Profile  
 
 Post subject: Well by deep copy I mean...
PostPosted: Mon Mar 28, 2005 2:46 pm 
Regular
Regular

Joined: Thu Sep 09, 2004 6:46 pm
Posts: 96
TheObject newObject = deepCopy(oldObject);

where oldObject has i.e: id=4
and new object has id=null until persisted.

oldObject has children objects with the oldObject Id relating to them and on persisting the child objects with inherit the new id from the parent.

Is there a way to do this?


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