persistence@glassfish.java.net

Re: java.lang.IllegalStateException: During synchronization a new object was found through a relationship that was not marked cascade PERSIST.

From: Mitesh Meswani <Mitesh.Meswani_at_Sun.COM>
Date: Wed, 10 Jan 2007 18:02:39 -0800

Hi Jon,

A fix has been checked in
<https://glassfish.dev.java.net/source/browse/glassfish/entity-persistence/src/java/oracle/toplink/essentials/internal/localization/i18n/ExceptionLocalizationResource.java?r1=1.14&r2=1.15>.
The error message now includes the offending object. Today's nightly
should contain the fix. Typically you get into this situation if you are
not maintaining both sides of your relationships. For example if you
have a domain model with Department and Employee with a bidirectional
relationship, if you do emp.setDepartment(newDepartment), you will need
to make sure to remove the employee from its old department's employees
collection and add it to newDeapartment's employee collection.

-Mitesh


Jon Miller wrote:
> Hi all,
>
> I'm running into the following exception. I'm wondering if anyone has
> suggestions on how to find the offending object? I'm thinking it might
> be nice if the error message did something like print the toString()
> representation of the offending object.
>
> Caused by: javax.faces.el.EvaluationException:
> javax.persistence.RollbackException: java.lang.IllegalStateException:
> During synchronization a new object was found through a relationship
> that was not marked cascade PERSIST.
>
> Jon