Java EclipseLink的CacheRetrieveMode.BYPASS无效

Java EclipseLink的CacheRetrieveMode.BYPASS无效,java,jpa,eclipselink,Java,Jpa,Eclipselink,按照我的代码: Company cc = em.find(Company.class, clientUser.getCompany().getId()); System.out.println(cc.getCompany_code()); HashMap findProperties = new HashMap(); findProperties.put(QueryHints.CACHE_RETRIEVE_MODE, CacheRetrieveMode.BYPASS); Company oo

按照我的代码:

Company cc = em.find(Company.class, clientUser.getCompany().getId());
System.out.println(cc.getCompany_code());

HashMap findProperties = new HashMap();
findProperties.put(QueryHints.CACHE_RETRIEVE_MODE, CacheRetrieveMode.BYPASS);

Company oo = em.find(Company.class, clientUser.getCompany().getId(), findProperties);
System.out.println(oo.getCompany_code());
就像“用作EntityManager属性”的示例一样


但是,这两种输出之间没有什么不同。

您希望有什么不同,为什么

请注意,CACHE_RETRIEVE_模式仅影响共享(第二级)缓存,而不影响持久性上下文(第一级缓存/事务性缓存),对于已读取的对象,必须始终在持久性上下文中维护对象标识

如果已更改数据库,并且需要新数据,请尝试使用新的EntityManager绕过,或者尝试使用refresh()

EclipseLink还提供查询提示“EclipseLink.maintain cache”=“false”以绕过持久性上下文


你用的是什么版本的EclipseLink?我相信在2.1版本中修复的2.0版本中有一个旁路错误。尝试最新版本。

您希望有什么不同,为什么

请注意,CACHE_RETRIEVE_模式仅影响共享(第二级)缓存,而不影响持久性上下文(第一级缓存/事务性缓存),对于已读取的对象,必须始终在持久性上下文中维护对象标识

如果已更改数据库,并且需要新数据,请尝试使用新的EntityManager绕过,或者尝试使用refresh()

EclipseLink还提供查询提示“EclipseLink.maintain cache”=“false”以绕过持久性上下文

你用的是什么版本的EclipseLink?我相信在2.1版本中修复的2.0版本中有一个旁路错误。请尝试最新版本