刷新Spring Data Repository中的Oracle实体化视图 [英] Refresh an Oracle Materialized view in a Spring Data Repository

查看:127
本文介绍了刷新Spring Data Repository中的Oracle实体化视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在查询Spring Data Repository之前,我需要刷新Oracle数据库中的物化视图。我试图通过存储库中的函数使用本地查询来完成此操作,如下所示。

I need to refresh a materialized view in an Oracle database before I query the Spring Data Repository. I'm attempting to do this via a function in the Repository with a native query, like the following.

@Query("BEGIN DBMS_SNAPSHOT.REFRESH('MY_VIEW', 'C'); END;", nativeQuery = true)
fun refreshMaterializedView()

但是,在调用此方法时,我得到了 java.lang.NegativeArraySizeException ,但它在直接在数据库上运行时工作正常。我在这里做错了什么?是否有另一种方法来强制物化视图刷新?

However, I am getting java.lang.NegativeArraySizeException when calling this method, although it works fine when being run directly on the database. What am I doing wrong here? Is there an alternative way to force the materialized view to refresh?

推荐答案

您需要使用 @Modifying 。它是真正用于DML语句,但也适用于此。

You need to annotate your method with @Modifying. It is really intended for DML statements but works for this as well.

@Modifying
@Query("BEGIN DBMS_SNAPSHOT.REFRESH('MY_VIEW', 'C'); END;", nativeQuery = true)
fun refreshMaterializedView()

这篇关于刷新Spring Data Repository中的Oracle实体化视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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