Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Entity instance not rollbacked
Entity instance not rollbacked [message #1016556] Wed, 06 March 2013 22:12 Go to next message
Cedric Tabin is currently offline Cedric TabinFriend
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

//... 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 ( Smile ) but the DynamicallyLoadedEntity loaded by my code above is persisted ( Evil or Very Mad ). 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 #1016774 is a reply to message #1016556] Thu, 07 March 2013 16:21 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1296
Registered: July 2009
Senior Member
Calling persist() should only push statements through the transaction when they are flushed, so I am not sure how not all statements would be rolledback.
Can you turn logging on to determine when the statements are issued, and show an example of how/where the transaction rollback is occuring?

That said, I do not believe you should be creating descriptors and adding them to the project directly in a JPA environment. Instead, you should be using the JPADynamicTypeBuilder described here:
with an example

and its classes:

Re: Entity instance not rollbacked [message #1017094 is a reply to message #1016774] Sat, 09 March 2013 00:53 Go to previous message
Cedric Tabin is currently offline Cedric TabinFriend
Messages: 2
Registered: March 2013
Junior Member

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.

Previous Topic:Switched to 2.4.1 - Suddenly caching of lazy relations is missing
Next Topic:Incorrect Cascade Discovery of new objects mapped from managed Embeddables
Goto Forum:

Current Time: Wed May 23 13:17:23 GMT 2018

Powered by FUDForum. Page generated in 0.01691 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top