-->
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.  [ 4 posts ] 
Author Message
 Post subject: Enforce insert for referenced object with an existing Id (?)
PostPosted: Tue Dec 21, 2004 1:07 pm 
Newbie

Joined: Tue May 25, 2004 4:24 am
Posts: 13
From documentation, I realized that Hibernate will determine whether to insert or update an object based on the object id, if null-> insert, else update (Reservation: when generator method is not assigned, e.g. identity).

If that so, I wonder whether I can enforce hibernate to insert the object although its Id exists.

Today, although the insert operation is cascading to the referenced objects, it recognizes that the objects were already created in the past and doesn't make the necessary duplication (of course with a new given ID)

Thanks in advance
Daphna


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 23, 2004 1:19 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
either set unsaved-value appropriatly, use version and unsaved-value or use Hibernate3 which check the DB in the value can't be guessed.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 24, 2004 4:45 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
Interceptor.unsaved() is also usefull

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Re: Enforce insert for referenced object with an existing Id
PostPosted: Fri Dec 24, 2004 9:43 am 
Contributor
Contributor

Joined: Thu Nov 06, 2003 9:49 pm
Posts: 104
Location: New York, NY
dtsur wrote:
From documentation, I realized that Hibernate will determine whether to insert or update an object based on the object id, if null-> insert, else update (Reservation: when generator method is not assigned, e.g. identity).

If that so, I wonder whether I can enforce hibernate to insert the object although its Id exists.

Today, although the insert operation is cascading to the referenced objects, it recognizes that the objects were already created in the past and doesn't make the necessary duplication (of course with a new given ID)

Thanks in advance
Daphna


Wouldn't that be very likely to result in PK constraint violations?


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