Skip to main content



      Home
Home » Eclipse Projects » EclipseLink » Building object hierarchy causes synchronization
Building object hierarchy causes synchronization [message #547133] Thu, 15 July 2010 12:20 Go to next message
Eclipse UserFriend
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 13:17 Go to previous message
Eclipse UserFriend
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.
Previous Topic:org.eclipse.persistence.exceptions.ValidationException
Next Topic:Getting Session Using JpaHelper.getEntityManager
Goto Forum:
  


Current Time: Tue Jul 01 14:28:11 EDT 2025

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

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

Back to the top