Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-dev] em.flush() stores data in database in a rolled back transaction

I was using MyISAM. I just checked that 

1) MyISAM does not support transactions - which is probably why you cannot do a thing about it
2) It works with InnoDB

On 25.02.2009, at 17:52, Gordon Yorke wrote:

Have you created the MYSQL database with the INNIDB engine?  Have you tried your example on another database?
--Gordon

Gregor Zeitlinger wrote:
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 {
}

_______________________________________________ eclipselink-dev mailing list eclipselink-dev@xxxxxxxxxxx https://dev.eclipse.org/mailman/listinfo/eclipselink-dev
_______________________________________________
eclipselink-dev mailing list
eclipselink-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-dev


Back to the top