我遇到了刷新物化视图(POSGRESQL)的问题,使用以下代码:
String hql = "refresh materialized view mv_all_operations; refresh materialized view mv_all_members;";
createQuery(hql).executeUpdate();
异常:
antlr.NoViableAltException: unexpected token: refresh
at org.hibernate.hql.internal.antlr.HqlBaseParser.statement(HqlBaseParser.java:169) ~[hibernate-core-4.2.7.Final.jar:4.2.7.Final]
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:268) ~[hibernate-core-4.2.7.Final.jar:4.2.7.Final]
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:182) ~[hibernate-core-4.2.7.Final.jar:4.2.7.Final]
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:138) ~[hibernate-core-4.2.7.Final.jar:4.2.7.Final]
at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:105) [hibernate-core-4.2.7.Final.jar:4.2.7.Final]
at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:80) [hibernate-core-4.2.7.Final.jar:4.2.7.Final]
at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:168) [hibernate-core-4.2.7.Final.jar:4.2.7.Final]
at org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:221) [hibernate-core-4.2.7.Final.jar:4.2.7.Final]
at org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:199) [hibernate-core-4.2.7.Final.jar:4.2.7.Final]
at org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:1784) [hibernate-core-4.2.7.Final.jar:4.2.7.Final]
看起来我不能用这种方式更新我的视图,但我找不到其他机会在代码中进行此操作。有什么建议吗?