Hi,

How are you adding the entity listeners(directly to the entities or to
entity manager factory)? If you add it for the entity, I doubt, it's
possible to get the reference to current em.

As I use Spring framework, it's quite easy:-) The
MyEntityLifecycleEventHandler adds itself as a listener to emf and listens
to all changes.
((OpenJPAEntityManagerFactorySPI)
emf).addLifecycleListener(entityLifecycleEventHandler , (Class[]) null);

Also this is a Spring managed bean in my case, so then one can use
@PersistenceContext to inject the current entity manager. Although, I've not
used it like this, as I didn't have such a requirement, I believe, it should
work.

If you're not using spring, then I don't know other ways. sorry! (Probably,
you should manage setting the current em to entityLifecycleEventHandler
every time!)

HTH,
Prashant


On Jan 20, 2008 6:33 PM, Miroslav Nachev <[EMAIL PROTECTED]> wrote:

>  Hi,
>
> I am writing this message again because until now I haven't answer and in
> the same time this is very important for my application.
> Can somebody help me?
>
> Regards,
> Miro.
>
>
>
> Miroslav Nachev wrote:
>
> In JDBCSeq, StoreContext (JDBCStore can be retrieved) is passed as
> parameter. If this can be passed as parameter in callback methods or if it
> can be retrieved from some OpenJPA Utility will be very good.
> Do you have any ideas or suggestion? Can you help me?
>
>
> Miro.
>
> On 1/17/08, Miroslav Nachev <[EMAIL PROTECTED]> wrote:
> >
> > Hi,
> >
> > In callback methods (PreRemove, PreUpdate, PrePersist, PostRemove,
> > PostUpdate, PostPersist) of an Entity Bean I need to execute native SQL
> > statement in the same transaction. How to retrieve current EntityManager
> > from which to get Connection object?
> > Are there any helper tools in OpenJPA for that purpose?
> >
> >
> > Regards,
> > Miro.
> >
>
>
>

Reply via email to