[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [eclipselink-users] Optimistic Lock Exception expected
|
James,
is there any chance that a fix for this is available any time soon?
Thanks,
Tino
James Sutherland schrieb:
Looking at the code, the merge() is not throwing an error for versioned
objects that were deleted. Please log a bug for this and post the id, so I
can also vote for it.
Mathias Koehnke - Sun Microsystems wrote:
Hi,
Enclosed, you'll find the source code of the entity/main class and log
output:
public class Main {
private static EntityManagerFactory emf;
public static void main(String[] args) {
JpaHelper.getServerSession(getEntityManagerFactory()).getProject().assumeExistenceForDoesExist();
SimpleEntity entity = new SimpleEntity();
entity.setValue("entity");
//persist "entity" and create clone "entityCopy"
EntityManager em1 =
getEntityManagerFactory().createEntityManager();
em1.getTransaction().begin();
em1.persist(entity);
em1.getTransaction().commit();
SimpleEntity entityCopy = em1.find(SimpleEntity.class,
entity.getId());
em1.close();
//delete "entity" from database
EntityManager em2 =
getEntityManagerFactory().createEntityManager();
em2.getTransaction().begin();
entity = em2.merge(entity);
em2.remove(entity);
em2.getTransaction().commit();
em2.close();
//merge clone "entityCopy" and commit
EntityManager em3 =
getEntityManagerFactory().createEntityManager();
em3.getTransaction().begin();
entityCopy = em3.merge(entityCopy);
em3.lock(entityCopy, LockModeType.WRITE);
em3.getTransaction().commit();
em3.close();
}
private static EntityManagerFactory getEntityManagerFactory() {
if (emf == null) {
emf =
Persistence.createEntityManagerFactory("EclipseLinkTestPU");
}
return emf;
}
-----
---
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland
http://www.eclipse.org/eclipselink/
EclipseLink , http://www.oracle.com/technology/products/ias/toplink/
TopLink
Wiki: http://wiki.eclipse.org/EclipseLink EclipseLink ,
http://wiki.oracle.com/page/TopLink TopLink
Forums: http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink ,
http://www.nabble.com/EclipseLink-f26430.html EclipseLink
Book: http://en.wikibooks.org/wiki/Java_Persistence Java Persistence
--
Sun Microsystems GmbH Tino Rachui
Nagelsweg 55 Desktop Virtualisierung
Hamburg Sun Ray Entwicklung
Germany Phone: +49(0)40 23646928
http://www.sun.de
mailto:tino.rachui@xxxxxxx
Sitz der Gesellschaft: Sun Microsystems GmbH, Sonnenallee 1,
D-85551 Kirchheim-Heimstetten
Amtsgericht Muenchen: HRB 161028
Geschaeftsfuehrer: Thomas Schröder, Wolfgang Engels, Dr. Roland Boemer
Vorsitzender des Aufsichtsrates: Martin Haering