美文网首页
jpa-手动清理缓存

jpa-手动清理缓存

作者: JavaHub | 来源:发表于2022-01-06 14:56 被阅读0次

jpa缓存图


image.png

场景:
1.批处理场景(缓存使用太大,频繁full gc)
2.native query 或者 DML 之后(缓存和数据库数据不一致)

解决方法:
EntityManager.flush();
EntityManager.clear();

特殊场景:
多数据源场景下,需要手动注入对应数据源的EntityManager。

相关文章

网友评论

      本文标题:jpa-手动清理缓存

      本文链接:https://www.haomeiwen.com/subject/mwfrcrtx.html