如何修复 eclipselink.refresh 对 JPQL 中的此类查询无效?
How to fix eclipselink.refresh is not valid for this type of query in JPQL?
我正在尝试通过 JPQL 更新 table 列,我的其余查询如下所示。
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>
我可以进行所有类型的 select 操作,但是在更新方面,我做不到,我认为这与我在 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]
CUBA 不支持通过 rest v2 查询进行批量更新 api。您可以为此使用休息服务调用。请参阅有关它的文档:https://doc.cuba-platform.com/manual-6.5/rest_api_v2_services_config.html
我正在尝试通过 JPQL 更新 table 列,我的其余查询如下所示。
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>
我可以进行所有类型的 select 操作,但是在更新方面,我做不到,我认为这与我在 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]
CUBA 不支持通过 rest v2 查询进行批量更新 api。您可以为此使用休息服务调用。请参阅有关它的文档:https://doc.cuba-platform.com/manual-6.5/rest_api_v2_services_config.html