Hi Prashant, Thanks for the ideas. Unfortunately I am using GlassFish v2 (EJB 3) but I think that you give some ideas to try. If this is not working I will ask again the community. Also I have one idea to hacl OpenJPA as follow: 1. Check if the callback method StoreContext as parameter; 2. If the 1st point is true, then pass StoreContext to that callback method.
Miro. On 1/20/08, Prashant Bhat <[EMAIL PROTECTED]> wrote: > > 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. > > > > > > > > > >
