简体   繁体   中英

How to fix eclipselink.refresh is not valid for this type of query in JPQL?

I am trying to update a table column via JPQL, My rest query looks some this like below.

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>

I am able to do all sort of select operations, but when it comes to updating, I am not able to do, I think it's related to How I am querying in JPQL. I googled but I did not find anything very close to a solution.

Also note, I am using cuba-platform and rest queries. The exception trace is below - hope it is helpful.

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]

CUBA does not support batch updates via rest v2 query api. You can use rest service invocations for that. See the documentation about it: https://doc.cuba-platform.com/manual-6.5/rest_api_v2_services_config.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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