JPA - 在merge()之后无法立即刷新数据库 - getEntityManager()。refresh()无效

时间:2017-04-03 03:46:01

标签: hibernate jpa seam

我从列表视图页面编辑列表的值,并在调用getEntityManager()。merge()后遇到无法立即刷新数据库的问题。 所以,我必须再次 刷新,以便系统返回我编辑的准确数据 结果,甚至称为getEntityManager()。refresh()但仍然没有效果。

getEntityManager().merge(transactions);
getEntityManager().flush();
getEntityManager().refresh(transactions);

在发布此问题之前,我已经研究了很多这个问题的帖子,这花了我很多时间。 对不起,我的英文不好或编码不好。我是新手。 非常感谢!

1 个答案:

答案 0 :(得分:0)

我已经找到了我的解决方案..这与Jboss Seam框架有点相关我正在使用
为了显示列表页面视图,我使用了Seam的 EntityQuery getEntityManage() 。编辑它,我正在使用 EntityHome 的getEntityManage()。 这导致EntityHome中的refresh()或clear()无论如何都没有效果,并且在我重新加载页面之前仍然存储缓存。
我应该在 EntityQuery 的getEntityManage中清除缓存,而不是通过调用列表搜索查询来清除 EntityHome 中的缓存或者只是在 EntityQuery 中调用getEntityManage.clear() 希望这有用!感谢