简体   繁体   English

Weblogic + JPA不会刷新Oracle数据库上的数据

[英]Weblogic + JPA don't refresh data on Oracle database

I have a system based on Oracle10g (datasource) + Weblogic 10.3 + Eclipselink. 我有一个基于Oracle10g(数据源)+ Weblogic 10.3 + Eclipselink的系统。

If I insert or delete data via the Java software with DAOs, all the data are immediately avaliable, but if I manually insert data (via SqlDeveloper or using the java.sql.Connection class), the new data are not brought from database. 如果我通过带有DAO的Java软件插入或删除数据,则所有数据都立即可用,但是如果我手动插入数据(通过SqlDeveloper或使用java.sql.Connection类),则不会从数据库中获取新数据。
Why it happens? 为什么会发生? And how to fix it? 以及如何解决?

It happens because EclipseLink cannot be aware that changes are made to database via some other methods. 发生这种情况是因为EclipseLink无法意识到通过其他方法对数据库进行了更改。 External tools do not inform EclipseLink about changes and EclipseLink is not all the time polling database content for possible changes. 外部工具不会将更改告知EclipseLink,并且EclipseLink并非一直在轮询数据库内容以查找可能的更改。 Such a implementation would kill performance. 这样的实现会降低性能。 Same happens also with changes made via JPA bulk operations, like JPQL and native SQL DELETE and INSERT queries. 通过JPA批量操作(如JPQL和本机SQL DELETE和INSERT查询)进行的更改也会发生同样的情况。

You cannot really fix the problem, but it is easier to live with it, when you turn of shared cache. 您无法真正解决问题,但是在打开共享缓存时更容易解决。 Be aware of likely performance hit. 请注意可能会对性能造成影响。

In JPA 1: 在JPA 1中:

<property name="eclipselink.cache.shared.default" value="false"/>  

and in JPA 2: 在JPA 2中:

<shared-cache-mode>NONE</shared-cache-mode>

As an addition of shared cache, also EntityManager maintains cache. 作为共享缓存的补充,EntityManager也维护缓存。 Single entity can refreshed from database via refresh method. 可以通过刷新方法从数据库刷新单个实体。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM