ONLY_COMMIT_NEWLY_CREATED_TRANSACTIONS, false,
new TransactionTask<Object>() {
@Override
public Object doInTransaction(TransactionStatus transaction) throws Throwable {
info.set();
Setting setting = new Setting().setValue("value").setName(name).
setDataType(SettingDataType.STRING).setInternal(false).setPosition(1);
_entityManager.persist(setting);
_entityManager.flush();
return null;
}
});
info.assertIsSameTransaction(transaction);
info.assertNotNew();
info.assertIsNotCompleted();
info.assertIsNotRollbackOnly();
assertTrue(_entityManager.getReference(Setting.class, name) != null);
} finally {
_tm.rollback(transaction);
}
assertFalse(_entityManager.getReference(Setting.class, name) != null);
}
});
TransactionlessTesting.get().run(new TestTask() {
@Override
public void run() throws Exception {
final String name = UUID.randomUUID().toString();
final TransactionInformation info = new TransactionInformation();
TransactionAspect.runInTransaction("testRunInTransactionSimpleWrite", _applicationContext, CREATE_ONLY_WHEN_NEEDED,
ONLY_COMMIT_NEWLY_CREATED_TRANSACTIONS, false,
new TransactionTask<Object>() {
@Override
public Object doInTransaction(TransactionStatus transaction) throws Throwable {
info.set();
Setting setting = new Setting().setValue("value").setName(name).
setDataType(SettingDataType.STRING).setInternal(false).setPosition(1);
_entityManager.persist(setting);
_entityManager.flush();
return null;
}