Hi Daryl,
Yes I have a piece of code that allows me to duplicate it at will.
The main object is new, but the attached entities are not new, the members
are populated by retrieving existing entities use em.find.
If I set cascade type to PERSIST I get a different error but basically
complaining about the same thing:
SEVERE: Encountered new object in persistent field
"com.trm.core.Asset.vendor" during attach. However, this field does not
allow cascade attach. Set the cascade attribute for this field to
CascadeType.MERGE or CascadeType.ALL (JPA annotations) or "merge" or "all"
(JPA orm.xml). You cannot attach a reference to a new object without
cascading.
<openjpa-1.2.1-r752877:753278 nonfatal user error>
org.apache.openjpa.persistence.ArgumentException: Encountered new object in
persistent field "com.trm.core.Asset.vendor" during attach. However, this
field does not allow cascade attach. Set the cascade attribute for this
field to CascadeType.MERGE or CascadeType.ALL (JPA annotations) or "merge"
or "all" (JPA orm.xml). You cannot attach a reference to a new object
without cascading.
FailedObject: com.trm.core.suppl...@175831e
at
org.apache.openjpa.kernel.AttachStrategy.getReference(AttachStrategy.java:28
1)
at
org.apache.openjpa.kernel.AttachStrategy.attachField(AttachStrategy.java:194
)
at
org.apache.openjpa.kernel.VersionAttachStrategy.attach(VersionAttachStrategy
.java:153)
at
org.apache.openjpa.kernel.AttachManager.attach(AttachManager.java:241)
at
org.apache.openjpa.kernel.AttachManager.attach(AttachManager.java:101)
at org.apache.openjpa.kernel.BrokerImpl.attach(BrokerImpl.java:3212)
at
org.apache.openjpa.kernel.DelegatingBroker.attach(DelegatingBroker.java:1158
)
at
org.apache.openjpa.persistence.EntityManagerImpl.merge(EntityManagerImpl.jav
a:769)
Let me debug it and see if sm is null
Chris
-----Original Message-----
From: Daryl Stultz [mailto:[email protected]]
Sent: Thursday, 17 September 2009 2:36 AM
To: OpenJPA User List
Subject: Re: SingleFieldManager crash
On Wed, Sep 16, 2009 at 2:20 PM, C N Davies <[email protected]> wrote:
> Hi Daryl,
>
> I get the same error as you can see from my stack trace below:
...
> FailedObject: com.trm.core.suppl...@3002b9
> My error occurs when I create new Entity and populate some of the fields
> with other entities, each of the fields are set to cascade type of
REFRESH.
>
> My case isn't quite the same as yours: it looks like your FailedObject is
new (there is no ID after the Hash), I'm not using CascadeType.REFRESH, and
my case is not at all repeatable. It may happen one in a thousand times.
If yours is repeatable, perhaps you could debug the code and tell me if it
fails because sm is null or !sm.isPersistent(). If your failed object is
indeed new I'm guessing it fails on sm == null. If you use
CascadeType.PERSIST does it go away?
Thanks.
--
Daryl Stultz
_____________________________________
6 Degrees Software and Consulting, Inc.
http://www.6degrees.com
mailto:[email protected]