monetschemist opened a new issue, #14216:
URL: https://github.com/apache/grails-core/issues/14216

   I'm having a hard time describing this, but basically in the index view on 
any table in my project, if I click on the column heading to sort fields, 
things work fine, except when I click on a column whose elements are 
many-to-many; that generates a crash.
   
   I'm at the very earliest stages in the application, just prototyping the 
data model.  The views, controllers and services are the stock ones generated 
by "grails generate-all".   The image attached shows the index page; clicking 
on either  of the two rightmost columns causes the code to crash; all other 
columns sort just fine.
   
   ![Screenshot from 2020-09-14 
16-04-44](https://user-images.githubusercontent.com/7864478/93146638-31df2b00-f6a4-11ea-8bbf-75fa689f4bd6.png)
   
   The crash looks like this:
   
   ```
   ArrayIndexOutOfBoundsException occurred when processing request: [GET] 
/ocupante/index - parameters:
   sort: actividades
   max: 10
   order: asc
   0. 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:967)
           at 
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:901)
           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:1149)
           at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
           at java.lang.Thread.run(Thread.java:748)
   Caused by: java.lang.ArrayIndexOutOfBoundsException: 0
           at org.hibernate.criterion.Order.toSqlString(Order.java:119)
           at 
org.hibernate.loader.criteria.CriteriaQueryTranslator.getOrderBy(CriteriaQueryTranslator.java:414)
           at 
org.hibernate.loader.criteria.CriteriaJoinWalker.<init>(CriteriaJoinWalker.java:106)
           at 
org.hibernate.loader.criteria.CriteriaJoinWalker.<init>(CriteriaJoinWalker.java:75)
           at 
org.hibernate.loader.criteria.CriteriaLoader.<init>(CriteriaLoader.java:80)
           at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1773)
           at org.hibernate.internal.CriteriaImpl.list(CriteriaImpl.java:363)
           at 
org.grails.orm.hibernate.query.AbstractHibernateQuery.listForCriteria(AbstractHibernateQuery.java:719)
           at 
org.grails.orm.hibernate.query.AbstractHibernateQuery.list(AbstractHibernateQuery.java:709)
           at grails.gorm.PagedResultList.<init>(PagedResultList.java:43)
           at 
grails.gorm.DetachedCriteria$_list_closure2.doCall(DetachedCriteria.groovy:137)
           at 
grails.gorm.DetachedCriteria$_withPopulatedQuery_closure8.doCall(DetachedCriteria.groovy:769)
           at 
org.grails.datastore.gorm.GormStaticApi$_withDatastoreSession_closure24.doCall(GormStaticApi.groovy:862)
           at 
org.grails.datastore.mapping.core.DatastoreUtils.execute(DatastoreUtils.java:319)
           at 
org.grails.datastore.gorm.AbstractDatastoreApi.execute(AbstractDatastoreApi.groovy:40)
           at 
org.grails.datastore.gorm.GormStaticApi.withDatastoreSession(GormStaticApi.groovy:861)
           at 
grails.gorm.DetachedCriteria.withPopulatedQuery(DetachedCriteria.groovy:740)
           at grails.gorm.DetachedCriteria.list(DetachedCriteria.groovy:135)
           at 
grails.gorm.transactions.GrailsTransactionTemplate$2.doInTransaction(GrailsTransactionTemplate.groovy:94)
           at 
org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133)
           at 
grails.gorm.transactions.GrailsTransactionTemplate.execute(GrailsTransactionTemplate.groovy:91)
           at sgs.OcupanteController.index(OcupanteController.groovy:14)
           ... 14 common frames omitted
   ```
   
   
   The code in the controller that provokes this is the "respond" below at line 
14:
   
   ```
   package sgs
   
   import grails.validation.ValidationException
   import static org.springframework.http.HttpStatus.*
   
   class OcupanteController {
   
       OcupanteService ocupanteService
   
       static allowedMethods = [save: "POST", update: "PUT", delete: "DELETE"]
   
       def index(Integer max) {
           params.max = Math.min(max ?: 10, 100)
           respond ocupanteService.list(params), model:[ocupanteCount: 
ocupanteService.count()]
       }
   
   
   ```
   
   I'm at the very earliest stages in the application, just prototyping the 
data model.  The views, controllers and services are the stock ones generated 
by "grails generate-all".   The image attached shows the index page; clicking 
on either  of the two rightmost columns causes the code to crash; all other 
columns sort just fine.
   
   ![Screenshot from 2020-09-14 
16-04-44](https://user-images.githubusercontent.com/7864478/93146638-31df2b00-f6a4-11ea-8bbf-75fa689f4bd6.png)
   
   
   gradle.properties:
   grailsVersion=3.3.9
   gormVersion=6.1.11.RELEASE
   gradleWrapperVersion=3.5
   


-- 
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]

Reply via email to