开发者

CacheRetrieveMode.BYPASS of EclipseLink is not useful

Follow my code:

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, clie开发者_开发百科ntUser.getCompany().getId(), findProperties);
System.out.println(oo.getCompany_code());

Just like the example "Used as EntityManager properties". here

But, there are nothing different between the two outputs.


What are you expecting to be different and why?

Note that CACHE_RETRIEVE_MODE only affects the shared (2nd level) cache, not the persistence context (1st level cache/transactional cache), object identity must always be maintained in the persistence context for objects that have already been read.

If you have changed your database, and expect the new data then try the BYPASS using a new EntityManager, or try using refresh().

EclipseLink also provides the query hint "eclipselink.maintain-cache"="false" to bypass the persistence context as well.

What version of EclipseLink are you using? I believe there was a bug in BYPASS in the 2.0 release that was fixed in 2.1. Try the latest release.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜