users@glassfish.java.net

Re: EntityListener, PreUpdate, EJBContext

From: Laird Nelson <ljnelson_at_gmail.com>
Date: Fri, 20 Apr 2012 08:47:04 -0400

On Thu, Apr 19, 2012 at 8:46 PM, Mitesh Meswani
<mitesh.meswani_at_oracle.com>wrote:

> 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.
> /
>

Thanks for the pointer! It sounds like my solution (and the hundreds like
it that show up in Google results apparently erroneously) that currently
uses @PreUpdate should be using @PrePersist instead, and when it does so it
should find the EJBContext in the appropriate location in JNDI. Might be
worthy of a blog entry.

Thanks,
Laird

-- 
http://about.me/lairdnelson