通过JPA / Eclipselink无法看到更新的数据(在数据库中) [英] Updated data (in Database) is not visible via JPA/Eclipselink

查看:276
本文介绍了通过JPA / Eclipselink无法看到更新的数据(在数据库中)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有使用JPA / Eclipselink连接到数据库的Oracle DB和Java项目。

问题是当数据库中的某些数据更新时(手动使用Oracle SQL开发人员),这个数据是通过JPA看不到,只有旧值。

什么会导致这样的问题?

I have Oracle DB and Java project which is connected to the DB using JPA/Eclipselink.
The problem is that when some data updated in the database (manually using Oracle SQL developer), this data is not visible via JPA, only old values.
What can cause such problems?

推荐答案

请尝试< a href =http://download.oracle.com/javaee/5/api/javax/persistence/EntityManager.html#refresh%28java.lang.Object%29 =nofollow> em.refresh()

JPA的EntityManager将不知道您在事务之外所做的任何更改,直到重新加载数据为止。上面的命令将使它重新加载数据。

Please try em.refresh()
JPA's EntityManager will be unaware of any changes you made outside its transaction till it reloads the data. Above command will make it reload the data.

如果是List(使用select填充),那么你需要重新加载它。

If it is a List (populated using select), then you'll need to reload it.

这篇关于通过JPA / Eclipselink无法看到更新的数据(在数据库中)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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