Author: epbernard
Date: 2006-09-26 16:24:38 -0400 (Tue, 26 Sep 2006)
New Revision: 10532
Modified:
trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/emops/MergeTest.java
trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/emops/Race.java
Log:
more tests
Modified: trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/emops/MergeTest.java
===================================================================
--- trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/emops/MergeTest.java 2006-09-26
15:54:00 UTC (rev 10531)
+++ trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/emops/MergeTest.java 2006-09-26
20:24:38 UTC (rev 10532)
@@ -54,6 +54,38 @@
em.close();
}
+ public void testConcurrentMerge() {
+ Race race = new Race();
+ race.name = "Derby";
+ EntityManager em = factory.createEntityManager();
+ em.getTransaction().begin();
+ em.persist( race );
+ em.flush();
+ em.getTransaction().commit();
+ em.close();
+
+ race.name = "Magnicourt";
+
+ em = factory.createEntityManager();
+ em.getTransaction().begin();
+ Race race2 = em.find(Race.class, race.id );
+ race2.name = "Mans";
+
+ race = em.merge( race );
+ em.flush();
+ em.getTransaction().commit();
+ em.close();
+
+ em = factory.createEntityManager();
+ em.getTransaction().begin();
+ race2 = em.find(Race.class, race.id );
+ assertEquals( "Last commit win in merge", "Magnicourt", race2.name
);
+
+ em.remove( race2 );
+ em.getTransaction().commit();
+ em.close();
+ }
+
public Class[] getAnnotatedClasses() {
return new Class[] {
Race.class,
Modified: trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/emops/Race.java
===================================================================
--- trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/emops/Race.java 2006-09-26
15:54:00 UTC (rev 10531)
+++ trunk/HibernateExt/ejb/src/test/org/hibernate/ejb/test/emops/Race.java 2006-09-26
20:24:38 UTC (rev 10532)
@@ -21,4 +21,5 @@
@IndexColumn( name="index" ) @OneToMany(cascade = CascadeType.ALL, fetch =
FetchType.EAGER)
@org.hibernate.annotations.Cascade( { org.hibernate.annotations.CascadeType.ALL,
org.hibernate.annotations.CascadeType.DELETE_ORPHAN })
public List<Competitor> competitors = new ArrayList<Competitor>();
+ public String name;
}