如何修复eclipselink.refresh对于JPQL中的此类查询无效?

时间:2017-08-01 14:50:38

标签: java jpql cuba-platform

我正在尝试通过JPQL更新表列,我的其余查询看起来像下面这样。

http://localhost:6765/salesfactory/rest/v2/queries/sales$Applications/update?status=KILLED&appID=a896f3e5-9abc-a9a1-f14d-24c9eb22896a

        <jpql> <![CDATA[
                   UPDATE sales$Applications v
                   SET v.status = :status
                   WHERE v.id = :appID
                ]]>
        </jpql>
        <params>
            <param name="status" type="java.lang.String"/>
            <param name="appID" type="java.util.UUID"/>
        </params>

    </query>

我能够进行各种选择操作,但是当涉及到更新时,我无法做到,我认为这与我如何查询JPQL有关。我用谷歌搜索,但我找不到任何非常接近解决方案的东西。

另请注意,我正在使用cuba-platform and rest queries.下面的异常跟踪 - 希望它有用。

2017-08-01 09:40:53.201 DEBUG [http-nio-6765-exec-3/salesfactory] com.haulmont.restapi.auth.CubaRestLastSecurityFilter - REST API request [anonymous] GET http://localhost:6765/salesfactory/rest/v2/queries/sales$Applications/update?status=KILLED&appID=a896f3e5-9abc-a9a1-f14d-24c9eb22896a 0:0:0:0:0:0:0:1
2017-08-01 09:40:53.218 DEBUG [http-nio-6765-exec-3/salesfactory-core/anonymous] com.haulmont.cuba.core.app.RdbmsStore - loadList: metaClass=sales$Applications, view=sales.entity.Applications/applications-rest-view-1, query=UPDATE sales$Applications v SET v.status = :status WHERE v.id = :appID, max=10000
2017-08-01 09:40:53.237 ERROR [http-nio-6765-exec-3/salesfactory-core/anonymous] com.haulmont.cuba.core.sys.ServiceInterceptor - Exception: 
java.lang.IllegalArgumentException: Query  
                   UPDATE sales$Applications v
                   SET v.status = :status
                   WHERE v.id = :appID

        , query hint eclipselink.refresh is not valid for this type of query.
    at org.eclipse.persistence.internal.jpa.QueryHintsHandler$RefreshHint.applyToDatabaseQuery(QueryHintsHandler.java:822) ~[eclipselink-2.6.2.cuba15.jar:2.6.2.cuba15]
    at org.eclipse.persistence.internal.jpa.QueryHintsHandler$Hint.apply(QueryHintsHandler.java:369) ~[eclipselink-2.6.2.cuba15.jar:2.6.2.cuba15]
    at org.eclipse.persistence.internal.jpa.QueryHintsHandler$Hint.apply(QueryHintsHandler.java:347) ~[eclipselink-2.6.2.cuba15.jar:2.6.2.cuba15]
    at org.eclipse.persistence.internal.jpa.QueryHintsHandler.apply(QueryHintsHandler.java:172) ~[eclipselink-2.6.2.cuba15.jar:2.6.2.cuba15]
    at org.eclipse.persistence.internal.jpa.QueryImpl.setHintInternal(QueryImpl.java:767) ~[eclipselink-2.6.2.cuba15.jar:2.6.2.cuba15]
    at org.eclipse.persistence.internal.jpa.EJBQueryImpl.setHint(EJBQueryImpl.java:283) ~[eclipselink-2.6.2.cuba15.jar:2.6.2.cuba15]
    at com.haulmont.cuba.core.sys.QueryImpl.getQuery(QueryImpl.java:125) ~[cuba-core-6.5.5.jar:6.5.5]
    at com.haulmont.cuba.core.sys.QueryImpl.getResultList(QueryImpl.java:312) ~[cuba-core-6.5.5.jar:6.5.5]
    at com.haulmont.cuba.core.app.RdbmsStore.executeQuery(RdbmsStore.java:644) ~[cuba-core-6.5.5.jar:6.5.5]
    at com.haulmont.cuba.core.app.RdbmsStore.getResultList(RdbmsStore.java:552) ~[cuba-core-6.5.5.jar:6.5.5]
    at com.haulmont.cuba.core.app.RdbmsStore.loadList(RdbmsStore.java:195) ~[cuba-core-6.5.5.jar:6.5.5]
    at com.haulmont.cuba.core.app.DataManagerBean.loadList(DataManagerBean.java:84) ~[cuba-core-6.5.5.jar:6.5.5]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_131]

1 个答案:

答案 0 :(得分:3)

CUBA不支持通过rest v2 query api进行批量更新。您可以使用其他服务调用。请参阅相关文档:https://doc.cuba-platform.com/manual-6.5/rest_api_v2_services_config.html