使用 hibernate.cfg.xml 进行 Envers 配置
我正在尝试使用 Envers 来审核表中的更新/插入。我在数据库中创建了扩展名为 _AUDIT 的审计表。
但是当我实际运行该应用程序时,我在审计表中没有看到任何条目。我什至没有抛出任何错误或异常。条目正在插入主表中,但 AUDIT 表不会更新。
这是我的 ENVERS 配置:
hibernate.cfg.xml:
<!-- Hibernate ENVERS Configuration -->
<property name="org.hibernate.envers.audit_table_suffix">_AUDIT</property>
<property name="org.hibernate.envers.revision_field_name">REVISION_ID</property>
<property name="org.hibernate.envers.revision_type_field_name">REVTYPE</property>
<property name="org.hibernate.envers.do_not_audit_optimistic_locking_field">true</property>
<property name="org.hibernate.envers.default_schema">ROCC</property>
<!-- Hibernate ENVERS Listener Configuration -->
<listener class="org.hibernate.envers.event.AuditEventListener" type="post-insert"/>
<listener class="org.hibernate.envers.event.AuditEventListener" type="post-update"/>
<listener class="org.hibernate.envers.event.AuditEventListener" type="post-delete"/>
<listener class="org.hibernate.envers.event.AuditEventListener" type="pre-collection-update"/>
<listener class="org.hibernate.envers.event.AuditEventListener" type="pre-collection-remove"/>
<listener class="org.hibernate.envers.event.AuditEventListener" type="post-collection-recreate"/>
我的表如下:
/**
* Transaction generated by hbm2java
*/
@Audited
@Entity
@Table(name = "TRANSACTION", schema = "ROCC")
public class TransactionTable implements java.io.Serializable{...}
审计表是同一架构中的 TRANSACTION_AUDIT 。
谁能告诉我为什么审计不起作用?
I am trying to use Envers to audit the updates/inserts into my tables. I have created audit tables with extension _AUDIT in the DB.
But when I actually run the application, I dont see any entries in the audit tables. I even have no errors or exceptions thrown. Entries are being inserted into the main tables but the AUDIT tables are not updated.
Here is my ENVERS configuration :
hibernate.cfg.xml:
<!-- Hibernate ENVERS Configuration -->
<property name="org.hibernate.envers.audit_table_suffix">_AUDIT</property>
<property name="org.hibernate.envers.revision_field_name">REVISION_ID</property>
<property name="org.hibernate.envers.revision_type_field_name">REVTYPE</property>
<property name="org.hibernate.envers.do_not_audit_optimistic_locking_field">true</property>
<property name="org.hibernate.envers.default_schema">ROCC</property>
<!-- Hibernate ENVERS Listener Configuration -->
<listener class="org.hibernate.envers.event.AuditEventListener" type="post-insert"/>
<listener class="org.hibernate.envers.event.AuditEventListener" type="post-update"/>
<listener class="org.hibernate.envers.event.AuditEventListener" type="post-delete"/>
<listener class="org.hibernate.envers.event.AuditEventListener" type="pre-collection-update"/>
<listener class="org.hibernate.envers.event.AuditEventListener" type="pre-collection-remove"/>
<listener class="org.hibernate.envers.event.AuditEventListener" type="post-collection-recreate"/>
My table is as follows:
/**
* Transaction generated by hbm2java
*/
@Audited
@Entity
@Table(name = "TRANSACTION", schema = "ROCC")
public class TransactionTable implements java.io.Serializable{...}
The Audit table is TRANSACTION_AUDIT in the same schema.
Can any one tell me why the auditing is not working?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论