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: Jon Miller <jemiller_at_uchicago.edu>
Date: Wed, 10 Jan 2007 20:05:59 -0600

I don't know if this is a bug or not. I'm at a loss as to what might be the
problem. I'm receiving the following exception. It works OK with Hibernate,
but not with the version of TopLink that comes with NetBeans 5.5 or with V2
B30. I set my logging level to finest and I can see the objects that are
being "registered" into the persistence context. It looks like it's calling
toString() on my objects which prints the id values out. I can see that
there are only two objects which have null values (i.e. haven't been
persisted yet). One of the objects is the one that I'm calling merge() on
and the other is linked to that object with a CascadeType.ALL. The weird
thing is that if I call EntityManager.clear() first before I do my merge, it
works. When it fails, it seems to corrupt things even after I close the
EntityManager. i.e. I close the EntityManager and get a new one and receive
the exception when attempting to do other things like perform unrelated
queries.

Jon

----- Original Message -----
From: "Jon Miller" <jemiller_at_uchicago.edu>
To: "Glassfish Persistence List" <persistence_at_glassfish.dev.java.net>
Sent: Wednesday, January 10, 2007 6:13 PM
Subject: java.lang.IllegalStateException: During synchronization a new
object was found through a relationship that was not marked cascade PERSIST.


> 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
>