You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by "Nikita Timofeev (JIRA)" <ji...@apache.org> on 2017/02/27 08:10:45 UTC
[jira] [Closed] (CAY-2040) Database transactions can be committed
prematurely when using Cayenne PK generation
[ https://issues.apache.org/jira/browse/CAY-2040?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Nikita Timofeev closed CAY-2040.
--------------------------------
Resolution: Fixed
Fix Version/s: 4.0.M5
Fixed when using Cayenne transactions.
See CAY-2186 for additional information.
> Database transactions can be 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
> Fix For: 4.0.M5
>
>
> 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.15#6346)