openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pinaki Poddar <ppod...@apache.org>
Subject Re: Audit logging in OpenJPA2.1.
Date Sun, 05 Oct 2014 23:32:08 GMT
> Is there a way to implement such a logging in earlier versions of OpenJPA? 

Yes.

Core OpenJPA kernel has all the necessary functionality for audit
operations.
if you are *not* interested in the 'delta' between the current and
pre-change state of an entiity, the task becomes simpler. As you have noted
a standard LifCycle Event State change callback mechnism should suffice.

>  I cannot get a reference to entity manager in event listener.
You can albeit with some work.
The persistence entity when enhanced, implements a PersistenceCapable
interface. Hence, it is safe to cast the persistence entity to a
PersistenceCapable. The PersistenceCapable.pcGetGenericContext() method
returns you an object which is a Persistence Conext -- which is same (for
all practical purpose) as an EntityManager.
The Persistence Context in OpenJPA is called Broker. So it is safe to cast
the result of PersistenceCapable.pcGetGenericContext() to Broker. Broker has
all the methods you will find on an EntityManager. Actually EntityManager is
implemented as a very thin delegation layer on Broker.

You could always get a deeper and better explanation on the source (remember
OpenJPA is Open Source :) and JavaDoc.

Regards --




-----
Pinaki Poddar
Chair, Apache OpenJPA Project
--
View this message in context: http://openjpa.208410.n2.nabble.com/Audit-logging-in-OpenJPA2-1-tp7587161p7587171.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Mime
View raw message