-->
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.  [ 5 posts ] 
Author Message
 Post subject: <version> property is not updated on merge()
PostPosted: Thu Aug 18, 2005 2:53 pm 
Beginner
Beginner

Joined: Mon Sep 15, 2003 12:41 pm
Posts: 21
I have an integer <version> property. When I do merge(), the property gets incremented in the database, but not in the object itself. As a consequence, if I attempt to do another update using the same object, I get concurrent access exception (which is not correct).

I'm wondering if it's a feature of bug?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 18, 2005 3:56 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Feature :)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 18, 2005 4:17 pm 
Beginner
Beginner

Joined: Mon Sep 15, 2003 12:41 pm
Posts: 21
gavin wrote:
Feature :)


alright then. where can I read why is it done this way?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 18, 2005 4:21 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
You are supposed to do:

object = merge(object)

Never keep using an object after you merge it. It is stale.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 18, 2005 4:43 pm 
Beginner
Beginner

Joined: Mon Sep 15, 2003 12:41 pm
Posts: 21
gavin wrote:
You are supposed to do:
object = merge(object)
Never keep using an object after you merge it. It is stale.


oh, yeah, now I noticed the merge() return value finally...
nevertheless, it makes my DAO layer a bit inconsistent:

void save(Foo foo); // updates PK in foo itself
...
Foo update(Foo foo); // returns a copy instead

well, thanks for pointing out to the least expected direction -- source itself ;)


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