Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/382.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何在eclipselink中禁用缓存_Java_Caching_Jpa 2.0_Eclipselink - Fatal编程技术网

Java 如何在eclipselink中禁用缓存

Java 如何在eclipselink中禁用缓存,java,caching,jpa-2.0,eclipselink,Java,Caching,Jpa 2.0,Eclipselink,我已尝试使用persistence.xml中的以下属性禁用Eclipse indigo的EclipseLink中的二级缓存:- <property name="eclipselink.cache.shared.default" value="false"/> <shared-cache-mode>NONE</shared-cache-mode> 请帮我看看我是否遗漏了什么?或者我需要以其他方式执行吗???您已经禁用了对象缓存,但我认为您仍然可以使用查询缓存

我已尝试使用persistence.xml中的以下属性禁用Eclipse indigo的EclipseLink中的二级缓存:-

<property name="eclipselink.cache.shared.default" value="false"/>

<shared-cache-mode>NONE</shared-cache-mode>

请帮我看看我是否遗漏了什么?或者我需要以其他方式执行吗???

您已经禁用了对象缓存,但我认为您仍然可以使用查询缓存。您也应该能够使用禁用查询缓存

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

查询提示也可以设置同样的内容。如果persistence.xml配置似乎不起作用,您也可以尝试使用查询提示

还要注意,本质上,即使没有缓存,也会比较相同的对象,因此除非分离,否则应该是相同的

相关问题:


您已经禁用了对象缓存,但我认为您仍然可以使用查询缓存。您也应该能够使用禁用查询缓存

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

查询提示也可以设置同样的内容。如果persistence.xml配置似乎不起作用,您也可以尝试使用查询提示

还要注意,本质上,即使没有缓存,也会比较相同的对象,因此除非分离,否则应该是相同的

相关问题:


在调用的每个函数中添加此行。我在查看视图时使用find函数

((JpaEntityManager)em.getDelegate()).getServerSession().getIdentityMapAccessor().invalidateAll();
此行在运行反查询之前清除缓存

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

在调用的每个函数中添加此行。我在查看视图时使用find函数

((JpaEntityManager)em.getDelegate()).getServerSession().getIdentityMapAccessor().invalidateAll();
此行在运行反查询之前清除缓存

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

这段代码完全抽象出了EclipseLink/JPA,因此很难验证您是否使用单独的EntityManager实例进行查询。代码本身使您看起来像是在重用相同的referenceObjectRepository—这可能是问题的一部分吗?如果它正在重用相同的底层EntityManager实例,则需要返回相同的实体实例,除非清除该实例。此代码将EclipseLink/JPA完全抽象出来,因此很难验证您是否使用单独的EntityManager实例进行查询。代码本身使您看起来像是在重用相同的referenceObjectRepository—这可能是问题的一部分吗?如果它正在重用相同的底层EntityManager实例,则需要返回相同的实体实例,除非清除该实例。这是有效的!但只有在我创建了新的
EntityManager
时<代码>EntityManager e=Context.getFactory().createEntityManager()
((JpaEntityManager)e.getDelegate()).getServerSession().getIdentityMapAccessor().invalidateAll()这个有效!但只有在我创建了新的
EntityManager
时<代码>EntityManager e=Context.getFactory().createEntityManager()
((JpaEntityManager)e.getDelegate()).getServerSession().getIdentityMapAccessor().invalidateAll()