reset();
boolean gotException = false;
try {
EntityExc bean = getHome().create(new Integer(1), EntityExc.EXC_CREATEEXCEPTION|EntityExc.F_FAIL_POSTCREATE|EntityExc.F_SETROLLBACKONLY);
// No cache problem if failure happens in ejbCreate
// EntityExc bean = getHome().create(new Integer(1), EntityExc.EXC_CREATEEXCEPTION|EntityExc.F_SETROLLBACKONLY);
} catch (TransactionRolledbackException ex) {
gotException = true;
getLog().error("Got unexpected TransactionRolledbackException", ex);
getLog().error("Container started the transaction, so we should get the CreateException");
fail("EJB2.0 section 17.6.2.8 violation.");
} catch (CreateException ex) {
gotException = true;
getLog().debug("Got expected CreateException", ex);
} catch (Exception ex) {
gotException = true;
getLog().error("Unexpected exception", ex);
// Check if the bean instance was removed from the cache
// It isn't in the database, since the transaction was marked for rollback only
try {
EntityExc bean = getHome().findByPrimaryKey(new Integer(1), 0);
fail("Rolled back bean creation, but still in cache.");
} catch (AssertionFailedError ex2) {
// Just re-throw this
throw ex2;
} catch (FinderException ex2) {
//ex2.printStackTrace();
getLog().error("Got expected FinderException", ex2);
} catch (Throwable ex2) {
//ex2.printStackTrace();
getLog().error("Got unexpected exception", ex2);
}
fail("Unexpected exception: " + ex);
}
if (!gotException)
fail("Did not get expected CreateException.");
// Check if the bean instance was removed from the cache
// It isn't in the database, since the transaction was marked for rollback only
try {
EntityExc bean = getHome().findByPrimaryKey(new Integer(1), 0);
fail("Rolled back bean creation, but still in cache 2.");
} catch (AssertionFailedError ex2) {
// Just re-throw this
throw ex2;
} catch (FinderException ex2) {