users@glassfish.java.net

Re: Entity beans, persistence and CascadeType.

From: Markus Fuchs <Markus.Fuchs_at_Sun.COM>
Date: Wed, 27 Jun 2007 22:30:57 -0700
Hi Ryan,

What do you mean by "update the newly generated ids for the detached Entity beans"? Id's should never be modified after once set.

Anyway, you might want to set CascadeType.ALL for this relationship. This way any new Books will be persisted when calling EntityManager.merge(anAuthor). Merge exchanges all books with managed copies in the book collection.

-- markus.

Ryan J wrote:
Thanks for the reply Markus.

That works fine on the server side.  In my case I'm using an application client and end up calling EntityManager.merge()
via a remote interface.  My application client is not on the same machine as the server and I don't know of an easy way
to determine and update the newly generated ids for the detached Entity beans that are on the client if I use
CascadeType.PERSIST.

Ryan

Markus Fuchs wrote:
  
Hi Ryan,

the Ids for both Author and Book are generated automatically by the
Persistence Provider, as you specified SEQUENCE Id generation. Just
specify CascadeType.PERSIST on the Author side of the relationship.

Thanks,

-- markus.

    

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net