Entity instance not rollbacked [message #1016556] |
Wed, 06 March 2013 17:12  |
Eclipse User |
|
|
|
Hello all,
I'm playing with EclipseLink to load dynamically simple entities from an external package. In order to do that, I manually create a new RelationalDescriptor with the following lines:
RelationalDescriptor descriptor = new RelationalDescriptor();
descriptor.setJavaClass(entity); //class loaded by a custom ClassLoader
descriptor.getQueryManager().checkDatabaseForDoesExist();
descriptor.setCacheIsolation(CacheIsolationType.ISOLATED);
//... do the mappings
DatabaseSessionImpl databaseSession = entityManager.getDatabaseSession();
databaseSession.addDescriptor(descriptor);
This seems to work well: I can now create a new entity, persist/update/delete it like it was a standard entity declared in my EJB project:
userTransaction.begin();
StandardEntity standard = new StandardEntity();
entityManager.persist(standard);
DynamicallyLoadedEntity dynamic = new DynamicallyLoadedEntity();
entityManager.persist(dynamic);
userTransaction.commit(); //both entities are persisted
However, when the UserTransaction is rollbacked, there is a strange behaviour: the StandardEntity is not persisted ( ) but the DynamicallyLoadedEntity loaded by my code above is persisted ( ). So it seems that the DynamicLoadedEntity lives outside the transaction context...
I tried to add also the RelationalDescriptor to the Project, to the UnitOfWork and so on, but no matter what, the entity is still persisted when there is a rollback. Probably I just missed an attribute either in the descriptor, but I don't know where to look.
Anyone has an idea ?
Thanks !
|
|
|
|
Re: Entity instance not rollbacked [message #1017094 is a reply to message #1016774] |
Fri, 08 March 2013 19:53  |
Eclipse User |
|
|
|
Hello,
Thanks for your reply ! I finally found out what was going on: I was using MyISAM table in MySQL instead of InnoDB... Since the transactions are not supported by the former, each time a push() was done by JPA, the entity was recorded, even if a rollback occurs later.
|
|
|
Powered by
FUDForum. Page generated in 0.04448 seconds