Check the entityInterceptor property in the Spring configuration

This rule flags the use of the entityInterceptor property defined on transaction managers that are commonly migrated when moving to WebSphere Application Server. The entityInterceptor property is not supported on all transaction managers. When an entity interceptor is defined for a transaction manager that does not support it, a run time error will occur.

If the entityInterceptor property flagged by this rule is a child property of a HibernateTransactionManager bean, and if you are planning to change this transaction manager, the entityInterceptor property will no longer be valid. If you are not planning to migrate this bean, ignore this rule.

If the entityInterceptor property flagged by this rule is a child property of a JtaTransactionManager or a WebSphereUowTransactionManager, this property is not valid and must be migrated.

The following transaction manager is frequently migrated to a JtaTransactionManager or a WebSphereUowTransactionManager transaction manager depending on the version of Hibernate you are using.

<bean id="txManagerWithAudit" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
<property name="entityInterceptor"><ref local="auditInterceptor"/></property>
</bean>

<bean id="auditInterceptor" class="com.ibm.issw.AuditLoggingInterceptor">
... bean definition here ...
</bean>

If you migrate org.springframework.orm.hibernate3.HibernateTransactionManager to use org.springframework.transaction.jta.JtaTransactionManager, the entityInterceptor property shown in the following example is no longer valid. It can be set on either the SessionFactory or the HibernateTemplate configuration.

<bean id="txManagerWithAudit" class="org.springframework.transaction.jta.JtaTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
<property name="entityInterceptor"><ref local="auditInterceptor"/></property>
</bean>

<bean id="auditInterceptor" class="com.ibm.issw.AuditLoggingInterceptor">
... bean definition here ...
</bean>

In this example, you could move the entityInterceptor property to the SessionFactory definition.

<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="entityInterceptor"><ref local="auditInterceptor"/></property>
</bean>

However, if the session factory is defined as org.springframework.jndi.JndiObjectFactoryBean, then the entityInterceptor property is not valid and the Hibernate template can be used.

The following example shows an example of using HibernateTemplate to define the entityInterceptor property.

<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory" ref="sessionFactory" />
<property name="entityInterceptor"><ref local="auditInterceptor"/></property>
</bean>

For additional information, see: