|
|
1
1
以我的两美分计 answer 通过EntityManager.refresh()或通过 provider specific query hints 在特定的查询中,或者通过如下所述使缓存无效 https://wiki.eclipse.org/EclipseLink/Examples/JPA/Caching#How_to_refresh_the_cache 最后一个选择是 turn off the second level cache . 这迫使查询总是从数据库数据而不是二级缓存将实体加载到EntityManager中。您可以降低过时数据的风险(但不能消除它,因为EntityManager需要为托管实体拥有自己的一级缓存,表示事务性缓存),但代价是重新加载和重建实体,如果其他线程以前读取过实体,则有时是不必要的。 哪种方法最好完全取决于应用程序及其预期用例。 |
|
|
2
0
别生气,没事
或者
|
|
|
ê¹ë¯¼ì¬ · 在六边形的建筑中,例外情况应该扔到哪里? 1 年前 |
|
|
Nisi Zenuni · JPA和MongoDB持久性 2 年前 |
|
Martin Pfeffer · Spring Boot JPA 2 年前 |
|
|
Manish · 数据库更新中乐观锁定的实现 2 年前 |
|
|
Eloi · JPA Buddy不生成版本化迁移,但喜欢我的数据库为空 2 年前 |