Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Building object hierarchy causes synchronization
Building object hierarchy causes synchronization [message #547133] Thu, 15 July 2010 16:20 Go to next message
Fericit Bostan is currently offline Fericit BostanFriend
Messages: 68
Registered: June 2010
Member
I'm using EclipseLink 2.0 with GlassFish 3.0.1 and running inside of a global transaction. I'm invoking a WebService/EJB that takes an object graph that I want to persist but need to assign the proper associations prior. In my WebService method, which is Transactional, I loop through a collection of objects owned by the parent. These objects in turn have collections and so on ... Prior to persisting these objects I need to perform lookups of existing objects and make the appropriate assignments.

The problem that I'm having is running through the first loop I manage to locate the objects and make the assignments. On the next iteration, when I perform a lookup for an existing object it causes the EntityManager to perform a synchronization and the new objects that have been associated to the managed objects are now trying to be persisted. Of course not all of my associations are complete and I get an exception due to a null value in a require association.
During synchronization a new object was found through a relationship that was not marked cascade PERSIST: com.soma.survey.entity.Answer[answerid=null].


So how do I prevent the EntityManager from performing the synchronization? Or should I be attempting this type of effort in a different fashion?

Thank you for the help...
Re: Building object hierarchy causes synchronization [message #547150 is a reply to message #547133] Thu, 15 July 2010 17:17 Go to previous message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

You can set the flushMode on a Query or EntityManager to avoid undesirable flushes.

See,
http://en.wikibooks.org/wiki/Java_Persistence/Querying#Flush _Mode

You can also set the flushMode for the whole persistence unit in EclipseLink in your persistence.xml.

You can also set your mapping to cascade persist, or change the order of your operations.


James : Wiki : Book : Blog : Twitter
Previous Topic:org.eclipse.persistence.exceptions.ValidationException
Next Topic:Getting Session Using JpaHelper.getEntityManager
Goto Forum:
  


Current Time: Tue Mar 19 05:18:02 GMT 2024

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

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

Back to the top