I think I've found a bug in eclipselink, but before I file it, I want to be sure it's really a bug:
1) EntityManager.persist(..) 2) EntittyManager.flush() 3) the transaction is rolled back (because an exception is thrown) 4) The data from (1) is stored in the database (as seen from the mysql command line)
As I understand flush, it should not commit the data. From http://download.oracle.com/docs/cd/B32110_01/web.1013/b28221/usclient005.htm#CIHCIBGB
... As Example 29-29 shows, you can use EntityManager method flush to send updates to the database within a transaction before the transaction is committed. ...
Here's the test code to reproduce the bug
@Stateless @Local(IMetaStorage.class) @Remote(IMetaStorageRemote.class) public class MetaStorage implements IMetaStorage, IMetaStorageRemote {
... @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) public void createDocument() { Document document = new Document(); em.persist(document); // flush to force ID update em.flush(); throw new StorageException(); } ... }
@ApplicationException(rollback=true) public class StorageException extends RuntimeException { } |