Page 1 of 1

About Question enthuware.oce-jpad.v6.2.599 :

Posted: Sat Dec 24, 2016 1:55 pm
by johnlong
otherwise passing an entity by value
Could you provide example how to pass entity by value?

Re: About Question enthuware.oce-jpad.v6.2.599 :

Posted: Sun Dec 25, 2016 12:58 pm
by admin
It already specifies an example, "e.g. to a separate application tier, through a remote interface, etc.".

Re: About Question enthuware.oce-jpad.v6.2.599 :

Posted: Sun Dec 25, 2016 6:30 pm
by johnlong
That will require serialization?

Re: About Question enthuware.oce-jpad.v6.2.599 :

Posted: Mon Dec 26, 2016 12:47 am
by admin
Yes, serialization is one mechanism which can be used to achieve pass by value semantics for objects.

Re: About Question enthuware.oce-jpad.v6.2.599 :

Posted: Wed Dec 28, 2016 7:48 am
by johnlong
So that would mean that entities are required to implement Serializable, but as I see provider does not enforce that.

Re: About Question enthuware.oce-jpad.v6.2.599 :

Posted: Wed Dec 28, 2016 7:59 am
by admin
It does not impose any restriction either about serializing them. Also, serialization is only one such mechanism. You could use your own custom mechanism to transfer the state of an object to another process and initialize a copy there using that state.

Re: About Question enthuware.oce-jpad.v6.2.599 :

Posted: Wed Dec 28, 2016 1:46 pm
by johnlong
Specification says:

If an entity instance is to be passed by value as a detached object (e.g., through a remote interface), the entity class must implement the Serializable interface.

Re: About Question enthuware.oce-jpad.v6.2.599 :

Posted: Thu Dec 29, 2016 1:52 am
by admin
johnlong wrote:Specification says:

If an entity instance is to be passed by value as a detached object (e.g., through a remote interface), the entity class must implement the Serializable interface.
OK, I missed reading that. Thanks for sharing.
Paul.

Re: About Question enthuware.oce-jpad.v6.2.599 :

Posted: Thu Dec 29, 2016 10:12 am
by johnlong
Thanks.

Re: About Question enthuware.oce-jpad.v6.2.599 :

Posted: Wed Jul 19, 2017 5:50 pm
by himaiMinh
In the explanation
A detached entity results from transaction commit if a transaction-scoped container-managed entity manager is used (see section 3.3); from transaction rollback (see section 3.3.2); from detaching the entity from the persistence context; from clearing the persistence context; from closing an entity manager; or from serializing an entity or otherwise passing an entity by value—e.g., to a separate application tier, through a remote interface, etc.
I think it is better to put "from closing an application managed entity manager" because we cannot explicitly close the container managed entity manager.