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: Thu, 11 Jan 2007 10:53:05 -0800
Hi Jon,

The fix should be in yesterday's nightly build of glassfish. Please extract toplink-essentials.jar from it (the standalone persistence bundle is only available for promoted builds).

It should be very easy to build from sources also. Following summarizes steps needed to just build entity-persistence module
 mkdir workspace
% cd workspace
% cvs -d :pserver:<userid>@cvs.dev.java.net:/cvs checkout glassfish/bootstrap


#
#Configure Build Variables as described in the build quick start guide step 2
# before proceeding further
#

cd glassfish/bootstrap
#checkout sources
maven -Dmodules=entity-persistence checkout
#bootstrap glassfish environment
maven bootstrap
#build entity-persistence
maven -Dmodules=entity-persistence build
Regards,
Mitesh


Jon Miller wrote:
Mitesh,

Thanks for the super fast enhancement on this. Much appreciated. Are there nightly binary builds, or, do you have to build it from the source? If the later, I'm wondering which projects I need to check out. I tried building from the source once before, but, from what I remember, I needed something more than just the persistence project.

Jon

----- Original Message ----- From: "Mitesh Meswani" <Mitesh.Meswani@Sun.COM>
To: <persistence@glassfish.dev.java.net>
Sent: Wednesday, January 10, 2007 8:02 PM
Subject: Re: java.lang.IllegalStateException: During synchronization a new object was found through a relationship that was not marked cascade PERSIST.


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