我们正在 WebSphere 中部署 Spring + JPA + Hibernate Web 应用程序。在该应用程序中,我们将所有休眠模型对象打包为一个单独的 jar 文件并作为共享库引用保存。我们的模型对象是基于注释的实体类。
我们面临的问题是除了@org.hibernate.annotations.Filter
, FilterDefs 注释之外,所有注释都工作正常。当我调用时, session.enableFilter("activeRecordFilter");
我得到一个异常,例如:
org.hibernate.HibernateException: No such filter configured [activeRecordFilter]
我们的模型对象定义是这样的
@javax.persistence.Entity
@org.hibernate.annotations.FilterDef(name = "activeRecordFilter", defaultCondition = "ACTV <> 'N'")
@org.hibernate.annotations.Filter(name = "activeRecordFilter")
@javax.persistence.Table(name = "ASSCTN", schema ="METADATA")
public class Association implements Serializable {
/**
* serialVersionUID to validate serialized object
*/
异常跟踪
org.hibernate.HibernateException: No such filter configured [activeRecordFilter]
at org.hibernate.impl.SessionFactoryImpl.getFilterDefinition(SessionFactoryImpl.java:1204)
at org.hibernate.engine.LoadQueryInfluencers.enableFilter(LoadQueryInfluencers.java:127)
at org.hibernate.impl.SessionImpl.enableFilter(SessionImpl.java:2035)
at com.metadata.common.baseclass.GenericDAOImpl.changeSoftDeleteFilterStatus(GenericDAOImpl.java:1228)
at com.metadata.common.baseclass.GenericDAOImpl.populatePredicateList(GenericDAOImpl.java:1044)
at com.metadata.common.baseclass.GenericDAOImpl.getIFGetResponse(GenericDAOImpl.java:425)
at com.metadata.common.baseclass.GenericDAOImpl$$FastClassByCGLIB$$db8e9c53.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:688)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:621)
at com.metadata.common.repository.EntityRepository$$EnhancerByCGLIB$$22a81be7.getIFGetResponse(<generated>)
at com.metadata.metadatamodule.dao.GetServiceDAO.getResults(GetServiceDAO.java:51)
at com.metadata.metadatamodule.bo.GetServiceBO.getResults(GetServiceBO.java:67)
at com.metadata.metadatamodule.bo.GetServiceBO$$FastClassByCGLIB$$42f9d8cc.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:688)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:621)
at com.metadata.metadatamodule.bo.GetServiceBO$$EnhancerByCGLIB$$78933e6b.getResults(<generated>)
at com.metadata.metadatamodule.genericservice.GetService.getResults(GetService.java:49)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:611)
at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60)
at