Disable caching in JPA (eclipselink)

前端 未结 8 1318
失恋的感觉
失恋的感觉 2020-11-29 02:09

I want to use JPA (eclipselink) to get data from my database. The database is changed by a number of other sources and I therefore want to go back to the database for every

8条回答
  •  春和景丽
    2020-11-29 02:35

    If manually modifying the attributes of the object, for example MyLocation. The above trick (CACHE_USAGE=CacheUsage.DoNotCheckCache, or eclipselink.query-results-cache=false) does not seem to work as I tried.

    So i tried to set another hint which is eclipselink.refresh, to true. then it works. I mean the manually changed attributes get retrieved.

    So as i understand, the above trick only ensure the it gets the correct objects. However, if the objects have been cached already, eclipselink just returns them without checking the freshness of the contents of the objects. Only when the hint eclipselink.refresh is set to true, will these objects get refreshed to reflect the latest attribute values.

提交回复
热议问题