我最终得到了AOP解决方案:
@Aspect@Componentpublic class EnableFilterAspect { @AfterReturning( pointcut="bean(entityManagerFactory) && execution(* createEntityManager(..))", returning="retVal") public void getSessionAfter(JoinPoint joinPoint, Object retVal) { if (retVal != null && EntityManager.class.isInstance(retVal)) { Session session = ((EntityManager) retVal).unwrap(Session.class); session.enableFilter("myFilter").setParameter("myParameter", "myValue"); } }}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)