Entity instance not rollbacked [message #1016556] |
Wed, 06 March 2013 22:12 |
Cedric Tabin Messages: 2 Registered: March 2013 |
Junior Member |
|
|
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 !
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03651 seconds