Java JPA - 同步数据库和实体 [英] Java JPA - Sync Database and Entity

查看:112
本文介绍了Java JPA - 同步数据库和实体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为我的企业应用程序使用JPA,当我将行的值更改为我的数据库表中相关实体(通过 find( - )获取)

I'm using JPA for my Enterprise Application, and when I change values of row into my database table the related entity (get it by a find(-)) isn't updated with new value.

我认为实体与数据库或简单缓存之间存在同步问题,那么,我该如何解决呢? / p>

I think that there is a problem of sync between entity and database or a simple cache, so, how can I solve it?

推荐答案

如果编辑不使用JPA的数据库行,您应该调用 EntityManager#refresh( - ) 使用由 find( - )作为参数获取的实体或调用 EntityManager#clear( - ) ,然后调用再次查找( - )

If you edit the database row not using the JPA you should invoke EntityManager#refresh(-) using the entity fetched by find(-) as a parameter or invoke EntityManager#clear(-) and then invoke the find(-) again.

这篇关于Java JPA - 同步数据库和实体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆