使用Spring在hibernate 3.5.5中配置Envers
我们有一个Spring文件,所以我们使用Hibernate-3.5.5 class=“org.springframework.orm.hibernate3.LocalSessionFactoryBean”>使用Spring在hibernate 3.5.5中配置Envers,hibernate,Hibernate,我们有一个Spring文件,所以我们使用Hibernate-3.5.5 class=“org.springframework.orm.hibernate3.LocalSessionFactoryBean”> Run.hbm.xml ${方言} net.sf.ehcache.hibernate.EhCacheProvider 真的 真的 假的 假的 假的 闭上 假的 更新 _稽核 修订版 旋转类型 SQN_OWN 假的 当我启动应用程序时,我得到一个
Run.hbm.xml
${方言}
net.sf.ehcache.hibernate.EhCacheProvider
真的
真的
假的
假的
假的
闭上
假的
更新
_稽核
修订版
旋转类型
SQN_OWN
假的
当我启动应用程序时,我得到一个错误:HibernateeException无法初始化侦听器。进一步调试后,错误来自以下位置的AuditConfiguration类:
音频配置(配置C){
Properties=cfg.getProperties()
ReflectionManager ReflectionManager=((AnnotationConfiguration)cfg).getReflectionManager();在classCastException上失败cfg不是AnnotationConfiguration的实例
我可能做错了什么?原因是在AuditConfiguration的构造函数中,配置类型强制转换为 AnnotationConfiguration。使用此spring上下文代码段,似乎已解决问题
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="namingStrategy">
<ref bean="namingStrategy" />
</property>
<property name="configurationClass">
<value>org.hibernate.cfg.AnnotationConfiguration</value>
</property>
org.hibernate.cfg.AnnotationConfiguration
<prop key="hibernate.dialect">${dialect}</prop>
<prop key="hibernate.cache.provider_class">
<!-- org.hibernate.cache.ehcacheprovider-->
net.sf.ehcache.hibernate.EhCacheProvider
</prop>
<prop key="hibernate.cache.use_query_cache">true</prop>
<prop key="hibernate.cache.use_second_level_cache">
true
</prop>
<prop key="hibernate.show_sql">false</prop>
<prop key="hibernate.connection.autocommit">false</prop>
<prop key="hibernate.format_sql">false</prop>
<prop key="hibernate.connection.release_mode">on_close</prop>
<prop key="hibernate.generate_statistics">false</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
<prop key="org.hibernate.envers.audit_table_suffix">_Audit</prop>
<prop key="org.hibernate.envers.revision_field_name">REV</prop>
<prop key="org.hibernate.envers.revision_type_field_name">REVTYPE</prop>
<prop key="org.hibernate.envers.default_schema">SQN_OWN</prop>
<prop key="org.hibernate.envers.revision_on_collection_change">false</prop>
<entry key="post-insert">
<bean class="org.hibernate.envers.event.AuditEventListener" />
</entry>
<entry key="post-update">
<bean class="org.hibernate.envers.event.AuditEventListener" />
</entry>
<entry key="post-delete">
<bean class="org.hibernate.envers.event.AuditEventListener" />
</entry>
<entry key="pre-collection-update">
<bean class="org.hibernate.envers.event.AuditEventListener" />
</entry>
<entry key="pre-collection-remove">
<bean class="org.hibernate.envers.event.AuditEventListener" />
</entry>
<entry key="post-collection-recreate">
<bean class="org.hibernate.envers.event.AuditEventListener" />
</entry>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="namingStrategy">
<ref bean="namingStrategy" />
</property>
<property name="configurationClass">
<value>org.hibernate.cfg.AnnotationConfiguration</value>
</property>