Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
4.0.M2
-
None
-
MySQL/Derby
Description
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:
TransactionTest.java
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()); }
The culprit seems to be PK generating code committing transaction when advancing AUTO_PK_SUPPORT next_id value.
Attachments
Issue Links
- is related to
-
CAY-2186 MySQL and Derby PK generators should not commit explicitly
- Open