CacheRetrieveMode.BYPASS of EclipseLink is not useful

前端 未结 1 1386
慢半拍i
慢半拍i 2021-01-16 09:19

Follow my code:

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

HashMap findProperties = new         


        
相关标签:
1条回答
  • 2021-01-16 09:41

    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 讨论(0)
提交回复
热议问题