Mitesh,
You were right. I wasn't managing my relationships correctly. I found out
what it was. That's interesting what you said about the cache being global
(I was assuming there was a cache per EntityManager). Does that mean that if
I call EntityManager.clear() on one EntityManager in one thread, it will
clear the objects that another thread using another EntityManager has in
it's cache? The way I've been doing things so far is I have a single
EntityManagerFactory which is shared between threads and each thread has
their own EntityManager.
Jon
----- Original Message -----
From: "Mitesh Meswani" <Mitesh.Meswani_at_Sun.COM>
To: <persistence_at_glassfish.dev.java.net>
Sent: Wednesday, January 10, 2007 8:24 PM
Subject: Re: java.lang.IllegalStateException: During synchronization a new
object was found through a relationship that was not marked cascade PERSIST.
> Hi Jon,
>
> The symptoms seem to indicate that somewhere there is a mismatch in
> relationship management. Please check. Toplink maintains a global object
> level cache (across transactions). Hence closing and opening an em will
> not help.
>
> -Mitesh
>
> Jon Miller wrote:
>> 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
>>>
>