What options do I have for configuring auditing of Entities

View: New views
2 Messages — Rating Filter:   Alert me  

What options do I have for configuring auditing of Entities

by fcalfo :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

So it looks like these are the options currently available to support auditing of data events on Entities (i.e., I want to insert a row into a separate audit table whenever a new Foo is persisted):

1) Register an Entity method as a DescriptorEvent handler
2) Register a separate class as a DescriptorEvent listener
3) Add the @PrePersist and @PreUpdate annotations to a method on the Entity (or its base class) - but this is probably of limited use since it does not provide the DescriptorEvent so a lot of the context will not be available for the audit logic

Are there any other options provided by EclipseLink?

Also, there do not seem to be any annotations to directly configure either of the first two options, correct?  I'd need to use a @Customizer so I can get access to the ClassDescriptor and get its EventManager to add the listeners to, correct?

Re: What options do I have for configuring auditing of Entities

by James Sutherland :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Those are the main event mechanisms.  There is currently no annotations/xml for DescriptorEvents, you must use a customizer, please log a bug/request for this.

Other options include performing the auditing logic in your application or data access layer, or in your database through triggers or database auditing features.

fcalfo wrote:
So it looks like these are the options currently available to support auditing of data events on Entities (i.e., I want to insert a row into a separate audit table whenever a new Foo is persisted):

1) Register an Entity method as a DescriptorEvent handler
2) Register a separate class as a DescriptorEvent listener
3) Add the @PrePersist and @PreUpdate annotations to a method on the Entity (or its base class) - but this is probably of limited use since it does not provide the DescriptorEvent so a lot of the context will not be available for the audit logic

Are there any other options provided by EclipseLink?

Also, there do not seem to be any annotations to directly configure either of the first two options, correct?  I'd need to use a @Customizer so I can get access to the ClassDescriptor and get its EventManager to add the listeners to, correct?