persistence@glassfish.java.net

Re: Listeners Problems

From: Marina Vatkina <Marina.Vatkina_at_Sun.COM>
Date: Mon, 28 Apr 2008 14:26:47 -0700

You can doo lookup in the entity as in any other helper class. This is what I
got from our EJB expert:


> It doesn't matter if it is an entity AS LONG AS the entity operation itself
> was called from a component.
>
> For example, if FooBean is an EJB *and if it can do the jndi lookup
> properly*, then the JPA entity also can do do the same lookup, as long as the
> EJB component is the "current" component in the calling stack.

HTH,
-marina

Markus KARG wrote:
> I am new to JPA and have some questions on correctly using listeners.
>
> I have an entity bean that shall do two things:
>
> (1) As soon as INSERT was done, its GeneratedValue ID shall be written into
> another data field. But if I try to modify any field inside of @PostPersist,
> those changes never occur in the database. Isn't it allowed to change an
> object after it got persisted? Or am I the only one that needs to have the
> generated valued copied in another field?
>
> (2) As soon as INSERT was done, a JMS message shall be sent. But how to
> obtain a JMS session inside of a EJB 3.0 entity (I knew how to do it in EJB
> 2.1)?
>
> I know I can workaround by modifying the calling code. But as I am
> programming a third party library, my customers shall not be forced to do all
> those things manually in their calling code.
>
> Any ideas?
>
> Thanks Markus
>