EntityManager pm2 = currentEntityManager();
startTx(pm1);
startTx(pm2);
DateVersion pc1 = (DateVersion) pm1.find(DateVersion.class, oid);
DateVersion pc2 = (DateVersion) pm2.find(DateVersion.class, oid);
pc1.setString ("pc-2-1");
pc2.setString ("pc-2-2");
// some DBs do not distinguish dates unless there is 1 sec diff
Thread.currentThread ().sleep (1 * 1000);
endTx(pm1);
try
{
Thread.currentThread ().sleep (1 * 1000);
endTx(pm2);
fail ("Should have caused OL exception.");
}
catch (Exception jfe)
{
startTx(pm2);
pm2.refresh (pc2);
pc2.setString ("pc-3-2");
endTx(pm2);
}
// make sure the next transaction works too
startTx(pm2);
pc2.setString ("pc-string-4-2");
endTx(pm2);
startTx(pm1);
pm1.refresh (pc1);
pc1.setString ("pc-string-3-1");
startTx(pm2);
pc2.setString ("pc-string-5-2");
Thread.currentThread ().sleep (1 * 1000);
endTx(pm1);
try
{
Thread.currentThread ().sleep (1 * 1000);
endTx(pm2);
fail ("Should have caused OL exception2.");
}
catch (Exception jfe)
{
startTx(pm2);
pm2.refresh (pc2);
pc2.setString ("pc-string-6-2");
endTx(pm2);
}
endEm(pm1);
endEm(pm2);
EntityManager pm = currentEntityManager();
DateVersion pc = pm.find(DateVersion.class, oid);
assertEquals ("pc-string-6-2", pc.toString ());
endEm(pm);
}