how to disable cache in eclipselink

后端 未结 2 1413
庸人自扰
庸人自扰 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);
    }
    
    0 讨论(0)
  • 2021-01-22 04:47

    You have disabled the object cache, but I think you still have query cache in play. You should be able to disable query cache too with

    <property name="eclipselink.query-results-cache" value="false"/>
    <property name="eclipselink.refresh" value="true"/>
    

    Same thing can be set with query hints, too. You could also try using query hints if persistence.xml configuration doesn't seem to be working.

    Also note that essentially, even without the caching, you'd be comparing the same object, so unless it is detached it should be the same.

    Related questions:

    • Disable eclipselink caching and query caching - not working?
    • Disable caching in JPA (eclipselink)
    0 讨论(0)
提交回复
热议问题