[jboss-dev-forums] [Design of EJB 3.0] - Unnecessary read before update with merge()
markvl2
do-not-reply at jboss.com
Wed Dec 6 19:43:06 EST 2006
Hope I'm not posting this to the wrong forum. I raised this first on the EJB3 and Hibernate user forums but have come to the conclusion it is a design / implementation issue with EJB3/Hibernate.
I have a simple case of an entity which is read in one thread, then updated in another thread using merge().
The Hibernate merge() code always reads the original value of a detached entity. From DefaultMergeEventListener.entityIsDetached():
| //we must clone embedded composite identifiers, or
| //we will get back the same instance that we pass in
| final Serializable clonedIdentifier = (Serializable) persister.getIdentifierType()
| .deepCopy( id, source.getEntityMode(), source.getFactory() );
| final Object result = source.get(entityName, clonedIdentifier);
|
It should be possible to update the entity without the original value of the entity being read from the DB. This is causing an unncecessary call to the DB.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3991824#3991824
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3991824
More information about the jboss-dev-forums
mailing list