users@glassfish.java.net

Re: EntityListener, PreUpdate, EJBContext

From: Mitesh Meswani <mitesh.meswani_at_oracle.com>
Date: Thu, 19 Apr 2012 17:46:18 -0700

Following from the spec answers it
/
The PrePersist and PreRemove callback methods are invoked for a given
entity before the
respective EntityManager persist and remove operations for that entity
are executed. For entities to
which the merge operation has been applied and causes the creation of
newly managed instances, the
PrePersist callback methods will be invoked for the managed instance
after the entity state has
been copied to it. These PrePersist and PreRemove callbacks will also be
invoked on all entities
to which these operations are cascaded. The PrePersist and PreRemove
methods will always be
invoked as part of the synchronous persist, merge, and remove operations.
/

On 4/19/2012 5:26 PM, Laird Nelson wrote:
> On Thu, Apr 19, 2012 at 4:44 PM, Mitesh Meswani
> <mitesh.meswani_at_oracle.com <mailto:mitesh.meswani_at_oracle.com>> wrote:
>
> >Root problem is the standard "I want to record who changed an
> object" issue.
> Did you try prepersist?
>
>
> No; my assumption (which I will double-check) was that @PrePersist was
> called on EntityManager#persist() operations. I need this to be
> called on merge() operations as well. Am I missing something?
>
> Best,
> Laird
>
> --
> http://about.me/lairdnelson
>