-->
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: Expected behaviour when merging a persistent instance
PostPosted: Tue Feb 13, 2007 1:39 am 
Newbie

Joined: Tue Feb 14, 2006 6:53 am
Posts: 7
I understand that the merge() method is to be used when reattaching detached instances, but what will happen in the following cases when working with persistent instances?

createEntityManager
find an ITEM
(the EntityManager doesn't get closed)
change some properties on ITEM
merge
commit
close EntityManager

OR

createEntityManager
create a new ITEM instance
(persist doesn't get called and the EntityManager doesn't get closed)
merge
commit
close EntityManager


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 15, 2007 7:32 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
1. merge is a no op and is useless, the item is already associated
2. merge will trigers the INSERT of your item

Note that merge does not reattach, it merges
PerssitentCopy = em.merge(detachedCopy);

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 21, 2007 5:40 pm 
Newbie

Joined: Tue Jan 16, 2007 8:43 pm
Posts: 5
Is there an EntityManager function that just reattaches a detached object to the session without doing all the checks/updates of merge()?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 21, 2007 11:29 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
no but session.lock(, LockMode.NONE) does what you want... I think

_________________
Emmanuel


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.