简体   繁体   English

Oracle数据库中的更改对于某些查询不可见

[英]Changes in Oracle database are not visible for a certain query

I have a large query which looks something like this: 我有一个大型查询,看起来像这样:

SELECT stuff, CASE WHEN (some subselect) > 0 THEN 'value 1' 
         WHEN (another subselect) > 0 THEN 'value 2' 
         ELSE 'value 3' END AS status
FROM (yet another subselect) e 

It works great. 效果很好。 But then, from Spring, trough JpaRepositories I make some changes which effect the some subselect part, but for some reason, these changes are not immediate. 但是,从Spring开始,我通过JpaRepositories进行了一些更改,这些更改会影响some subselect部分,但是由于某些原因,这些更改不是立即发生的。 In other queries the changes are visible, I tried using several transnational mechanism in Spring, tried not using transaction at all, I'm using saveAndFlush on the repositories, without any luck. 在其他查询中,更改是可见的,我尝试在Spring中使用几种跨国机制,尝试根本不使用事务,在存储库上使用saveAndFlush ,但没有任何运气。

But this delay also happened if I restarted the Tomcat server before the changes were visible. 但是,如果我在看到更改之前重新启动了Tomcat服务器,也会发生这种延迟。 This delay is also visible from an external db manipulation program, so I'm guessing the problem is not with my application. 从外部db操作程序中也可以看到此延迟,因此我猜测问题出在我的应用程序之外。

Can some kind of Oracle caches or transactions effect this? 某种Oracle缓存或事务会影响这种情况吗? How can I purge, flush, commit them? 我如何清除,冲洗,提交它们?

EDIT (for request in the comments): 编辑(在注释中请求):

In Java I only make basic changes 在Java中,我仅作基本更改

Java code Java代码

MyEntity myEntity = myEntityDao.findOne(someId);
myEntity.setProperty(newValue);
myEntityDao.saveAndFlush(myEntity);

Where myEntityDao looks something like myEntityDao看起来像

@Repository
public interface MyEntityDao extends JpaRepository<MyEntity, Integer> {
     //... other unrelated HQL query methods
}

Sorry I can't post anything more specific, but it's huge, and also, I just can't, for corporate reasons. 抱歉,我无法发布任何更具体的信息,但是由于公司原因,它太大了,我也无法发布。 Also note, that everything is working, but with a certain delay, between the modification and this one specific query. 还要注意,在修改和此特定查询之间,一切工作正常,但有一定的延迟。 Other queries can see the changes immediately. 其他查询可以立即看到更改。

Most probable reasons are: 最可能的原因是:
1) changes made in separate transaction and was not committed before query started. 1)在单独的事务中进行的更改,并且在查询开始之前未提交。
Oracle doesn't allow to read not committed changes from other transactions. Oracle不允许从其他事务读取未提交的更改。
And query returns consistent data to the moment of query start. 查询将在查询开始时返回一致的数据。
2) If you change transaction to "read only" or "serializable" then Oracle will return data consistent to transaction start. 2)如果将事务更改为“只读”或“可序列化”,则Oracle将返回与事务启动一致的数据。 So changes made in another transaction need to be committed before your read only transaction started. 因此,在只读事务开始之前,需要提交对另一个事务所做的更改。

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

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