关于JPA EclipseLink中 刷新缓存的问题(处女作)

来源:互联网 发布:外文期刊数据库 编辑:程序博客网 时间:2024/06/05 16:52

成功设置刷新缓存的方法是,如下


EntityManager em = Entity.entityManager();q1 = em.createNativeQuery("sql", XXX.class).setHint(QueryHints.REFRESH, HintValues.TRUE);


主要是设置 ( QueryHints.REFRESH, HintValues.TRUE)
另外据说在jpa的配置文件 persistence.xml中加上一段 
<property name="eclipselink.query-results-cache" value="false"/>

不过,我这个项目还不起作用。

persistence.xml

<?xml version="1.0" encoding="UTF-8" standalone="no"?><persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"><persistence-unit name="persistenceUnit" transaction-type="RESOURCE_LOCAL">        <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>        <validation-mode>NONE</validation-mode>        <properties>            <property name="eclipselink.target-database" value="com.sap.persistence.platform.database.HDBPlatform"/>            <!-- value="drop-and-create-tables" to build a new database on each run; value="create-tables" creates new tables if needed; value="none" makes no changes to the database -->            <property name="eclipselink.ddl-generation" value="none"/>            <property name="eclipselink.ddl-generation.output-mode" value="database"/>            <property name="eclipselink.weaving" value="static"/>            <property name="eclipselink.query-results-cache" value="false"/>        </properties>    </persistence-unit></persistence>


原创粉丝点击