1
我們有一個JBoss爲基礎的系統爲什麼攔截器的onLoad()不工作?
persistance.xml看起來像以下:
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0">
<persistence-unit name="solutions" transaction-type="JTA">
<jta-data-source>java:/mam</jta-data-source>
<class>....</class>
......
<class>....</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="hibernate.connection.datasource" value="java:/mam"/>
<property name="jboss.entity.manager.factory.jndi.name" value="java:/solutions"/>
<property name="hibernate.ejb.interceptor"
value="interceptor.AuditAndDeletableCatcherInterceptor"/>
<property name="hibernate.hbm2ddl.auto" value="validate"/>
<property name="hibernate.show_sql" value="false"/>
<property name="hibernate.format_sql" value="false"/>
<property name="hibernate.use_sql_comments" value="false"/>
<property name="hibernate.generate_statistics" value="false"/>
<property name="hibernate.bytecode.use_reflection_optimizer" value="cglib"/>
<property name="hibernate.dialect" value="com.magenta.componentization.audit.sql.MySQL5CustomDialect"/>
<property name="hibernate.query.substitutions" value="true 1, false 0"/>
<property name="hibernate.connection.provider_class"
value="org.hibernate.connection.DatasourceConnectionProvider"/>
<property name="hibernate.current_session_context_class" value="thread"/>
<property name="cache.provider_class" value="org.hibernate.cache.NoCacheProvider"/>
</properties>
</persistence-unit>
</persistence>
攔截器的代碼:
public class AuditAndDeletableCatcherInterceptor extends AuditInterceptor {
DeletableCatcherDeligate deletableCatcherDeligate =
new DeletableCatcherDeligate();
@Override
public boolean onLoad(Object o, Serializable serializable, Object[] objects, String[] strings, Type[] types) {
deletableCatcherDeligate.onLoad(o, serializable, objects, strings, types);
return super.onLoad(o, serializable, objects, strings, types);
}
}
凡AuditInterceptor擴展原生Hibernate的EmptyInterceptor 和超載喜歡的onSave一些方法(),onFlush(),onPreFlush()
AuditAn的一些方法dDeletableCatcherInterceptor工作,但onLoad()永遠不會被調用。 我在做什麼錯?