transaction1 = Transaction.begin();
if (transaction1.getAutoCommit())
{
fail("autocommit must be set to false for this test");
}
Author author1 = bookstoreContent.get(0);
author1.setName("new Author1");
author1.save(transaction1);
// lock author 2 in transaction 2
transaction2 = Transaction.begin();
if (transaction2.getAutoCommit())
{
fail("autocommit must be set to false for this test(2)");
}
Author author2 = bookstoreContent.get(1);
author2.setName("new Author2");
author2.save(transaction2);
// lock author 2 in transaction 1 (must wait for lock)
author2.setName("newer Author2");
SaveAndRollbackThread saveThreadTransaction1
= new SaveAndRollbackThread(
author2,
transaction1,
"saveThreadAuthor2Con1");
saveThreadTransaction1.start();
long startTime = System.currentTimeMillis();
while (!author2.isSaving() && author2.isModified()
&& saveThreadTransaction1.isAlive())
{
Thread.sleep(SLEEP_TIME);
if (System.currentTimeMillis() > startTime + TIMEOUT)
{