how to disable cache in eclipselink

后端 未结 2 1439
庸人自扰
庸人自扰 2021-01-22 03:55

I have tried disabling L2 cache in EclipseLink with Eclipse indigo by using following properties in persistence.xml:-



        
2条回答
  •  天涯浪人
    2021-01-22 04:37

    Add this line in each function where the call is made. I use in the find function when consulted a view.

    ((JpaEntityManager)em.getDelegate()).getServerSession().getIdentityMapAccessor().invalidateAll();
    

    This line clear the cache before run de query.

    public Entity find(Object id) {
        ((JpaEntityManager)em.getDelegate()).getServerSession().getIdentityMapAccessor().invalidateAll();
        return em.find(Entity.class, id);
    }
    

提交回复
热议问题