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
|