ilmoralito opened a new issue, #14610:
URL: https://github.com/apache/grails-core/issues/14610
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
1. Clone this repo
https://github.com/ilmoralito/Error-querying-basic-collection-types
2. Run the repo
3. 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
### Example Application
- TODO: https://github.com/ilmoralito/Error-querying-basic-collection-types
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]