Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Teneo/Hibernate/Auditing"

Line 23: Line 23:
  
 
== Retrieving Audit Entries ==
 
== Retrieving Audit Entries ==
 +
 +
Audit entries can be retrieved using the [http://git.eclipse.org/c/teneo/org.eclipse.emf.teneo.git/tree/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/auditing/AuditVersionProvider.java AuditVersionProvider]. The AuditVersionProvider can be retrieved from the data store using the getAuditVersionProvider method.
  
 
=== By Object ===
 
=== By Object ===
 +
 +
The AuditVersionProvider provides several methods to retrieve the history of an object. You can retrieve the latest audit entries or all audit entries for an object. See the getAllAuditEntries, getLatestAuditEntry methods.
 +
 +
From an audit entry you can find the next or previous entries using the getNextEntry and getPreviousEntry methods of the AuditVersionProvider.
  
 
=== Query ===
 
=== Query ===

Revision as of 19:09, 2 November 2012

Teneo supports auditing (from November 2012), a summary of the functionality:

  • auditing can be enabled for specific types
  • earlier versions of objects can be retrieved
  • possible to navigate/iterate over the history of an object
  • query for version history using attribute and ereference values

Enable auditing

Auditing can be enabled by calling setAuditing(true) on the datastore or setting the enable auditing option to true (see next section). To prevent auditing of specific types you can use the @NoAuditing annotation. Set this annotation in the EMF EAnnotation of the EClass using source 'teneo.jpa' and key 'value'.

Audit Entries

When auditing is enabled then each database action on an entity is persisted in a separate table. Each EClass will store its audit entries in a separate table. Teneo will store three types of events: ADD, UPDATE and DELETE. Teneo provides an api to retrieve the audit entries, this is described in more detail below.

Auditing Options

Teneo has many configuration options, three options are specific for auditing:

  • ENABLE_AUDITING (teneo.mapping.auditing.enable): default is false, enables auditing if set to "true"
  • AUDITING_ENTITY_PREFIX (teneo.naming.auditing.entity.prefix): defines the prefix which is set before the EClass name, this is used to compute the entity name and the table name used to store auditing entries.
  • AUDITING_ENTITY_PREFIX (teneo.naming.auditing.entity.prefix): defines the prefix which is set before the EClass name, this is used to compute the entity name and the table name used to store auditing entries.

Retrieving Audit Entries

Audit entries can be retrieved using the AuditVersionProvider. The AuditVersionProvider can be retrieved from the data store using the getAuditVersionProvider method.

By Object

The AuditVersionProvider provides several methods to retrieve the history of an object. You can retrieve the latest audit entries or all audit entries for an object. See the getAllAuditEntries, getLatestAuditEntry methods.

From an audit entry you can find the next or previous entries using the getNextEntry and getPreviousEntry methods of the AuditVersionProvider.

Query

Iterating over version history

Limitations

Auditing does not work in combination with specific functionality:

  • EmbeddedId is not supported, this is neither supported with Hibernate envers.
  • EAV mapping can not be combined with auditing. This can be solved but requires some work, please ask on the newsgroup if relevant for your case.
  • Embeddable/Embedded works fine but only if annotated in the model, so not using a separate xml/hbm mapping file. This can be solved but needs some work, please ask on the newsgroup if relevant for your case.
  • the delete audit entry does not contain any collection values

Back to the top