我正在尝试通过 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
和休息查询。 异常跟踪如下 - 希望它有帮助。
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]