You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by "Dzmitry Kazimirchyk (JIRA)" <ji...@apache.org> on 2015/12/02 09:19:11 UTC
[jira] [Created] (CAY-2040) Database transactions are committed
prematurely when using Cayenne PK generation
Dzmitry Kazimirchyk created CAY-2040:
----------------------------------------
Summary: Database transactions are committed prematurely when using Cayenne PK generation
Key: CAY-2040
URL: https://issues.apache.org/jira/browse/CAY-2040
Project: Cayenne
Issue Type: Bug
Components: Core Library
Affects Versions: 4.0.M2
Environment: MySQL/Derby
Reporter: Dzmitry Kazimirchyk
When using Cayenne PK generation (i.e. AUTO_PK_SUPPORT table) the following test will fail on the last assertion statement with select query returning 20 objects instead of 0:
{code:title=TransactionTest.java|borderStyle=solid}
public void testRollbackTransaction() {
assertEquals(0, ObjectSelect.query(Artist.class).select(context).size());
try {
runtime.performInTransaction(new TransactionalOperation<Object>() {
@Override
public Object perform() {
for (int i = 0; i < 30; i++) {
Artist artist = context.newObject(Artist.class);
artist.setArtistName("test" + i);
context.commitChanges();
}
context.newObject(Artist.class);
// this should fail with validation error
context.commitChanges();
return null;
}
});
} catch (Exception e) {
// ignore
}
assertEquals(0, ObjectSelect.query(Artist.class).select(context).size());
}
{code}
The culprit seems to be PK generating code committing transaction when advancing AUTO_PK_SUPPORT next_id value.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)