I'm looking to create a reusable audit table, that will log sql operations that occurred against "data sensitive" areas of the db.
The implementation is easy, in essence, I want to log the user's info who initiated the query, a timestamp and the query with any param values.
For the task on hand, the createNativeQuery()
is called from a javax.persistence.EntityManager
instance. This method returns a javax.persistence.Query
.
I've done some googling and reading through http://docs.oracle.com/javaee/6/api/javax/persistence/Query.html and haven't found an easy way to do what I'm looking to do.
Is there any easy way to get the "generated" version of the query? Or do I need to log the query string separate, and create my own way to iterating through all of the parameters to log things in the desired manner?