我需要执行 LIKE 查询。我创建如下:
AData ad : ao.find(AData.class, Query.select().where("user=? AND ISSUES LIKE %?%",user,issueId))) //issues field contain values as //"FIN-1,FIN-2,FIN7". issueId parameter has value as FIN-7
它给了我以下错误:
java.sql.SQLException: Unexpected token: % in statement [SELECT * FROM PUBLIC.AO_0371A8_ADATA WHERE user=? AND ISSUES LIKE %?%]
将以下查询更新为:
AData ad : ao.find(AData.class, Query.select().where("user=? AND ISSUES LIKE '%? %'",user,issueId))) //issues field contain values as //"FIN-1,FIN-2,FIN7". issueId parameter has
值为 FIN-7
它给了我以下错误:(参数索引超出范围:2)(也尝试为“.......LIKE \'%?%\'”......但给我与以下相同的错误:
com.atlassian.activeobjects.internal.ActiveObjectsSqlException: There was a SQL exception thrown by the Active Objects library:
Database:
- name:HSQL Database Engine
- version:1.8.0
- minor version:8
- major version:1
Driver:
- name:HSQL Database Engine Driver
- version:1.8.0
java.sql.SQLException: Invalid argument in JDBC call: parameter index out of range: 2
at com.atlassian.activeobjects.internal.EntityManagedActiveObjects.find(EntityManagedActiveObjects.java: 153)
at com.atlassian.activeobjects.osgi.DelegatingActiveObjects.find(DelegatingActiveObjects.java:81) <+3> (NativeMethodAccessorImpl.java:39) (DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
at org.springframework.osgi.service.importer.support.internal.aop.ServiceInvoker.doInvoke(ServiceInvoker.java:58)
at org.springframework.osgi.service.importer.support.internal.aop.ServiceInvoker.invoke(ServiceInvoker.j ava:62)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java: 171)
......
..
.
当尝试以下查询时:
AData ad : ao.find(AData.class, Query.select().where("user=? AND ISSUES LIKE '%?%' ",user,issueId)))
还有其他方式,
AData ad : ao.find(AData.class, Query.select().where("user=? AND ISSUES LIKE ? ",user, "%" +
issueId + "%")))
在上述两种情况下,都会出现以下错误:(主要错误是“java.sql.SQLException:JDBC 调用中的参数无效:参数索引超出范围:2”)。
Uncaught exception thrown by REST service
com.atlassian.activeobjects.internal.ActiveObjectsSqlException: There was a SQL exception thrown by the Active Objects library:
Database:
- name:HSQL Database Engine
- version:1.8.0
- minor version:8
- major version:1
Driver:
- name:HSQL Database Engine Driver
- version:1.8.0
java.sql.SQLException: Invalid argument in JDBC call: parameter index out of range: 2
at com.atlassian.activeobjects.internal.EntityManagedActiveObjects.find(EntityManagedActiveObjects.java: 153)
at com.atlassian.activeobjects.osgi.DelegatingActiveObjects.find(DelegatingActiveObjects.java:81) <+3> (NativeMethodAccessorImpl.java:39) (DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
at org.springframework.osgi.service.importer.support.internal.aop.ServiceInvoker.do
....
它是如何工作的......这个 LIKE 查询有什么问题?
谢谢你