Could not load requested class : org.hibernate.ejb.event.EJB3PostInsertEventListener,org.hibernate.envers.event.AuditEventListener
Could not load requested class : org.hibernate.ejb.event.EJB3PostInsertEventListener,org.hibernate.envers.event.AuditEventListener — такое исключение может возникнуть при работе с Hibernate Envers версий 4+.
При использовании Hibernate <4.0 в настройках для Hibernate Envers указывается следующее:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
<property name="jpaProperties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.H2Dialect</prop> <prop key="hibernate.max_fetch_depth">3</prop> <prop key="hibernate.jdbc.fetch_size">50</prop> <prop key="hibernate.jdbc.batch_size">10</prop> <prop key="hibernate.show_sql">true</prop> <!-- Listeners for Hibernate Envers --> <prop key="hibernate.ejb.event.post-insert"> org.hibernate.ejb.event.EJB3PostInsertEventListener,org.hibernate.envers.event.AuditEventListener </prop> <prop key="hibernate.ejb.event.post-update"> org.hibernate.ejb.event.EJB3PostUpdateEventListener,org.hibernate.envers.event.AuditEventListener </prop> <prop key="hibernate.ejb.event.post-delete"> org.hibernate.ejb.event.EJB3PostDeleteEventListener,org.hibernate.envers.event.AuditEventListener </prop> <prop key="hibernate.ejb.event.pre-collection-update"> org.hibernate.envers.event.AuditEventListener </prop> <prop key="hibernate.ejb.event.pre-collection-remove"> org.hibernate.envers.event.AuditEventListener </prop> <prop key="hibernate.ejb.event.post-collection-recreate"> org.hibernate.envers.event.AuditEventListener </prop> <!-- Properties for Hibernate Envers --> <prop key="org.hibernate.envers.audit_table_suffix">_H</prop> <prop key="org.hibernate.envers.revision_field_name">AUDIT_REVISION</prop> <prop key="org.hibernate.envers.revision_type_field_name">ACTION_TYPE</prop> <prop key="org.hibernate.envers.audit_strategy">org.hibernate.envers.strategy.ValidityAuditStrategy</prop> <prop key="org.hibernate.envers.audit_strategy_validity_end_rev_field_name">AUDIT_REVISION_END</prop> <prop key="org.hibernate.envers.audit_strategy_validity_store_revend_timestamp">true</prop> <prop key="org.hibernate.envers.audit_strategy_validity_revend_timestamp_field_name">AUDIT_REVISION_END_TS</prop> </props> </property> |
Для версий Hibernate Envers 4.0+ такие настройки в конфигурации spring-context.xml или persistence.xml больше не работают, т.к. больше не нужно указывать
1 2 3 4 5 6 7 8 |
<properties> <property name="hibernate.ejb.event.post-insert" value="org.hibernate.ejb.event.EJB3PostInsertEventListener,org.hibernate.envers.event.AuditEventListener" /> <property name="hibernate.ejb.event.post-update" value="org.hibernate.ejb.event.EJB3PostUpdateEventListener,org.hibernate.envers.event.AuditEventListener" /> <property name="hibernate.ejb.event.post-delete" value="org.hibernate.ejb.event.EJB3PostDeleteEventListener,org.hibernate.envers.event.AuditEventListener" /> <property name="hibernate.ejb.event.pre-collection-update" value="org.hibernate.envers.event.AuditEventListener" /> <property name="hibernate.ejb.event.pre-collection-remove" value="org.hibernate.envers.event.AuditEventListener" /> <property name="hibernate.ejb.event.post-collection-recreate" value="org.hibernate.envers.event.AuditEventListener" /> </properties> |
Т.е. нужно оставить только такой вариант (пример взят из статьи Hibernate Envers – отслеживание версий):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
<property name="jpaProperties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.H2Dialect</prop> <prop key="hibernate.max_fetch_depth">3</prop> <prop key="hibernate.jdbc.fetch_size">50</prop> <prop key="hibernate.jdbc.batch_size">10</prop> <prop key="hibernate.show_sql">true</prop> <!-- Properties for Hibernate Envers --> <prop key="org.hibernate.envers.audit_table_suffix">_H</prop> <prop key="org.hibernate.envers.revision_field_name">AUDIT_REVISION</prop> <prop key="org.hibernate.envers.revision_type_field_name">ACTION_TYPE</prop> <prop key="org.hibernate.envers.audit_strategy">org.hibernate.envers.strategy.ValidityAuditStrategy</prop> <prop key="org.hibernate.envers.audit_strategy_validity_end_rev_field_name">AUDIT_REVISION_END</prop> <prop key="org.hibernate.envers.audit_strategy_validity_store_revend_timestamp">true</prop> <prop key="org.hibernate.envers.audit_strategy_validity_revend_timestamp_field_name">AUDIT_REVISION_END_TS</prop> </props> </property> |
2
3925 Total Views 2 Views Today