<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=windows-1252"
http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
I confirm what I said. I added a testcase to HEM.<br>
<br>
Here is the most accurate thing I can find from the spec<br>
<tt><br>
3.4.2 Version Attributes<br>
[...]<br>
The persistence provider's implementation of the merge operation must
examine the version attribute<br>
when an entity is being merged and throw an OptimisticLockException if
it is discovered that<br>
the object being merged is a stale copy of the entity—i.e. that the
entity has been updated since the<br>
entity became detached. Depending on the implementation strategy used,
it is possible that this exception<br>
may not be thrown until flush is called or commit time, whichever
happens first.<br>
[...]</tt><br>
<br>
Christian Bauer wrote:
<blockquote cite="mid7AE2AA41-E8F1-4C5C-8E4D-F94870230A44@jboss.com"
type="cite">
<meta http-equiv="Content-Type" content="text/html; ">
<meta name="Generator" content="MS Exchange Server version 6.5.7638.1">
<title>[hibernate-dev] Snapshot conflict with merge</title>
<!-- Converted from text/plain format -->
<p><font size="2">I wrote (tested and verified with Gavin):<br>
<br>
Finally, merging doesn’t allow the following scenario, where two <br>
modifications conflict on one snapshot:<br>
<br>
item.getId() // The database identity is "1234"<br>
item.setDescription(...);<br>
<br>
Session session= sessionFactory.openSession();<br>
Transaction tx = session.beginTransaction();<br>
<br>
Item item2 = (Item) session.get(Item.class, new Long(1234));<br>
item2.setDescription(...); // Not allowed!<br>
<br>
return session.merge(item); // Throws exception!<br>
<br>
tx.commit();<br>
session.close();<br>
<br>
The detached object’s description is modified as well as the <br>
persistent object’s. There is no way for Hibernate to determine who <br>
will win in this situation and a StaleObjectStateException is thrown <br>
when you try to merge() onto a dirty persistent instance.<br>
<br>
Emmanuel comments:<br>
<br>
No exception is raised in my tests. The merged state takes precedence <br>
over the initially loaded and modified state (regardless the object <br>
has been versioned or not) AFAIR, the spec does not talk about such <br>
an exception either.<br>
<br>
What is it?<br>
<br>
<br>
_______________________________________________<br>
hibernate-dev mailing list<br>
<a class="moz-txt-link-abbreviated" href="mailto:hibernate-dev@lists.jboss.org">hibernate-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/hibernate-dev">https://lists.jboss.org/mailman/listinfo/hibernate-dev</a><br>
</font>
</p>
</blockquote>
</body>
</html>