Repository navigation
Description
JdbcSQLException occurred when try to query an association defined with Basic Collection Types
Having Student domain class, with the following body
class Student {
String name
String email
static constraints = {
name blank: false
email blank: false, unique: true, email: true
}
static hasMany = [schools: String]
static mapping = {
table 'students'
schools joinTable: [column: 'school']
}
}
And from an StudentController action
def index() {
List<String> emailList = Student.createCriteria().list {
'in'('schools', ['School2'])
projections {
property 'email'
}
}
render emailList
}
I am getting the following stacktrace
2017-06-21 16:22:23.146 ERROR --- [io-8080-exec-10] o.h.engine.jdbc.spi.SqlExceptionHelper : Parameter "#1" is not set; SQL statement:
select this_.email as y0_ from students this_ where this_.id in (?) [90012-194]
2017-06-21 16:22:23.188 ERROR --- [io-8080-exec-10] o.g.web.errors.GrailsExceptionResolver : JdbcSQLException occurred when processing request: [GET] /student/index
Parameter "#1" is not set; SQL statement:
select this_.email as y0_ from students this_ where this_.id in (?) [90012-194]. Stacktrace follows:
java.lang.reflect.InvocationTargetException: null
at org.grails.core.DefaultGrailsControllerClass$ReflectionInvoker.invoke(DefaultGrailsControllerClass.java:211)
at org.grails.core.DefaultGrailsControllerClass.invoke(DefaultGrailsControllerClass.java:188)
at org.grails.web.mapping.mvc.UrlMappingsInfoHandlerAdapter.handle(UrlMappingsInfoHandlerAdapter.groovy:90)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
at org.springframework.boot.web.filter.ApplicationContextHeaderFilter.doFilterInternal(ApplicationContextHeaderFilter.java:55)
at org.grails.web.servlet.mvc.GrailsWebRequestFilter.doFilterInternal(GrailsWebRequestFilter.java:77)
at org.grails.web.filters.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:67)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.hibernate.exception.GenericJDBCException: could not extract ResultSet
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:47)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:111)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:97)
at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:79)
at org.hibernate.loader.Loader.getResultSet(Loader.java:2122)
at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1905)
at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1881)
at org.hibernate.loader.Loader.doQuery(Loader.java:925)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:342)
at org.hibernate.loader.Loader.doList(Loader.java:2622)
at org.hibernate.loader.Loader.doList(Loader.java:2605)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2434)
at org.hibernate.loader.Loader.list(Loader.java:2429)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:109)
at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1787)
at org.hibernate.internal.CriteriaImpl.list(CriteriaImpl.java:363)
at org.grails.orm.hibernate.query.AbstractHibernateCriteriaBuilder.invokeMethod(AbstractHibernateCriteriaBuilder.java:1687)
at org.grails.orm.hibernate.query.AbstractHibernateCriteriaBuilder.list(AbstractHibernateCriteriaBuilder.java:1558)
at demo.app.StudentController.index(StudentController.groovy:6)
... 14 common frames omitted
Caused by: org.h2.jdbc.JdbcSQLException: Parameter "#1" is not set; SQL statement:
select this_.email as y0_ from students this_ where this_.id in (?) [90012-194]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
at org.h2.message.DbException.get(DbException.java:179)
at org.h2.message.DbException.get(DbException.java:155)
at org.h2.expression.Parameter.checkSet(Parameter.java:81)
at org.h2.command.Prepared.checkParameters(Prepared.java:164)
at org.h2.command.CommandContainer.query(CommandContainer.java:112)
at org.h2.command.Command.executeQuery(Command.java:201)
at org.h2.jdbc.JdbcPreparedStatement.executeQuery(JdbcPreparedStatement.java:110)
at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:70)
... 29 common frames omitted
Steps to Reproduce
- Clone this repo https://github.com/ilmoralito/Error-querying-basic-collection-types
- Run the repo
- Go to this location http://localhost:8080/student/index
Expected Behaviour
Should print a list of student emails
Actual Behaviour
Error 500: Internal Server Error
URI /student/index
Class org.h2.jdbc.JdbcSQLException
Message null
Caused by Parameter "#1" is not set; SQL statement: select this_.email as y0_ from students this_ where this_.id in (?) [90012-194]
Environment Information
- Operating System: Ubuntu
- Grails Version: Using grails version 3.2.9
- JDK Version: Using java version 8u121
Activity
dularion commentedon May 3, 2018
We have got the same issue. A workaround is to use HQL, but we really prefer criterias / where-queries. Are there any updates on this?
dularion commentedon May 4, 2018
I just found this old stackoverflow. Does something like this still work? https://stackoverflow.com/questions/8347726/how-to-make-a-query-with-usage-of-like-operator-over-a-string-collection-in-gorm?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa
although I would pose the questions: what is
userin that query?zyro23 commentedon May 4, 2018
maybe
elementsworks? ref. https://docs.jboss.org/hibernate/orm/current/userguide/html_single/Hibernate_User_Guide.html#criteria-collectionsdularion commentedon May 4, 2018
How would that look like exactly? I tried something like this:
but that doesnt work
zyro23 commentedon May 4, 2018
unfortunately, i think no luck with detached-criteria/where-queries.
but criteria should work:
jamesfredley commentedon Feb 26, 2026
We have verified that this issue still exists in Grails 7.x / GORM 8.x.
A reproduction test reproduces the exact same
Parameter "#1" is not seterror when using criteria queries with'in'operator on a basic collection type (hasManywithString).This will be addressed in an upcoming fix.
Fix basic collection type 'in' query (#14610)
Merge pull request #15463 from apache/fix/basic-collection-in-14610
fix: remove @PendingFeature from basic collection test now that #14610 …
Merge pull request #15471 from apache/fix/remove-pending-feature-basi…
fix(grails-data-neo4j): implement embedded-component support and fix …
fix(grails-data-neo4j): implement embedded-component support and fix …
fix(grails-data-neo4j): implement embedded-component support and fix …
fix(grails-data-neo4j): implement embedded-component support and fix …
Neo4j GormRegistry migration (consolidated: replaces #15816, #15951, #…