openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "C N Davies" <...@cndavies.com>
Subject RE: SingleFieldManager crash
Date Wed, 16 Sep 2009 19:47:54 GMT
Maybe mine is intermittent as well. The very same code is now showing the
same basic issue but a different stack trace, the one I sent earlier had
happened 5 minutes before you raised the issue on the list.

Maybe your code is managing the particular issue in the stack trace below,
but not the SingleFieldManager issue and that's why it's so intermittent for
you.

Here is my new stack trace, as you will see it is bitching about the same
thing but the stack is different. It is exactly the same code ( loads some
data from an XLS using POI) and exactly the same data. 

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.Supplier@d73a7a
	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)


-----Original Message-----
From: Daryl Stultz [mailto:daryl@6degrees.com] 
Sent: Thursday, 17 September 2009 3:08 AM
To: users@openjpa.apache.org
Subject: Re: SingleFieldManager crash

On Wed, Sep 16, 2009 at 2:48 PM, C N Davies <cnd@cndavies.com> wrote:

>
> The main object is new, but the attached entities are not new, the members
> are populated by retrieving existing entities use em.find.
>
> That is similar to my case, though usually the existing entities are from
a
query. I'm wondering why there is no primary key after the hash for
Supplier, I always get it.


> If I set cascade type to PERSIST I get a different error but basically
> complaining about the same thing:
>
> What about CascadeType.ALL?


> (JPA orm.xml). You cannot attach a reference to a new object without
> cascading.
>

I don't understand this statement at all and contend it's not true. I
totally do that all the time. That's why I'm so perplexed. I can even do
this:

A a = new A();
B b = new B();
b.setId(12);
a.setB(b);
em.persist(a);

and it works (provided B with ID of 12 exists in the database).

-- 
Daryl Stultz
_____________________________________
6 Degrees Software and Consulting, Inc.
http://www.6degrees.com
mailto:daryl@6degrees.com


Mime
View raw message