cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dzmitry Kazimirchyk (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (CAY-2040) Database transactions can be committed prematurely when using Cayenne PK generation
Date Wed, 02 Dec 2015 11:56:10 GMT

     [ https://issues.apache.org/jira/browse/CAY-2040?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Dzmitry Kazimirchyk updated CAY-2040:
-------------------------------------
    Summary: Database transactions can be committed prematurely when using Cayenne PK generation
 (was: Database transactions are committed prematurely when using Cayenne PK generation)

> 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
>
> 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)

Mime
View raw message