JBoss.org Community Documentation
The audit
element of the entity section allows one to specify how access to and entity bean is audited. This is only allowed when an entity bean is accessed under a security domain so that this is a caller identity established. The content model of the audit element is given Figure 12.5, “The jbosscmp-jdbc.xml audit element content model”.
created-by
: This optional element indicates that the caller who created the entity should be saved to either the indicated column-name
or cmp field-name
.
created-time
: This optional element indicates that the time of entity creation should be saved to either the indicated column-name
or cmp field-name
.
updated-by
: This optional element indicates that the caller who last modified the entity should be saved to either the indicated column-name
or CMP field-name
.
updated-time
: This optional element indicates that the last time of entity modification should be saved to either the indicated column-name
or CMP field-name
.
For each element, if a field-name
is given, the corresponding audit information should be stored in the specified CMP field of the entity bean being accessed. Note that there does not have to be an corresponding CMP field declared on the entity. In case there are matching field names, you will be able to access audit fields in the application using the corresponding CMP field abstract getters and setters. Otherwise, the audit fields will be created and added to the entity internally. You will be able to access audit information in EJB-QL queries using the audit field names, but not directly through the entity accessors.
If, on the other hand, a column-name
is specified, the corresponding audit information should be stored in the indicated column of the entity table. If JBoss is creating the table the jdbc-type
and sql-type
element can then be used to define the storage type.
The declaration of audit information with given column names is shown below.
<jbosscmp-jdbc> <enterprise-beans> <entity> <ejb-name>AuditChangedNamesEJB</ejb-name> <table-name>cmp2_audit_changednames</table-name> <audit> <created-by> <column-name>createdby</column-name> </created-by> <created-time> <column-name>createdtime</column-name> </created-time> <updated-by> <column-name>updatedby</column-name></updated-by> <updated-time> <column-name>updatedtime</column-name> </updated-time> </audit> </entity> </enterprise-beans> </jbosscmp-jdbc>