|Entity instance not rollbacked [message #1016556]
||Wed, 06 March 2013 22:12
| Cedric Tabin
Registered: March 2013
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
//... do the mappings
DatabaseSessionImpl databaseSession = entityManager.getDatabaseSession();
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:
StandardEntity standard = new StandardEntity();
DynamicallyLoadedEntity dynamic = new DynamicallyLoadedEntity();
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 ?
Powered by FUDForum
. Page generated in 0.01846 seconds