You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When trying to use Collection Set within namedParameters of ExecuteQuery It throws: java.lang.ClassCastException java.util.LinkedHashSet cannot be cast to java.lang.Long
I can convert the Collection Set to data type Collection List and it will work, but I was wondering why this was now occurring in Grails 3.1.11 when it didn't appear to occur in Grails 2.2.3 . Is this a genuine bug in Grails 3.1.11?
Expected Behaviour
ExecuteQuery handles named parameter of data type Collection Set just as it does with Collection List
Actual Behaviour
ClassCastException: java.util.LinkedHashSet cannot be cast to java.lang.Long
Example Code to Reproduce Issue
// A Mocked up Domain
class AccountExample {
Long id
String name
}
//Code that works
List idList = [2L, 3L, 5L, 7L, 11L, 13L]
List accountNameList1 = AccountExample.executeQuery(
"SELECT name FROM AccountExample WHERE id IN :ids", [ids:idList]
)
List accountNameList2 = AccountExample.executeQuery(
"SELECT name FROM AccountExample WHERE id IN (:ids)", [ids:idList]
)
//Code that fails in Grails 3.1.11 but not in Grails 2.2.3
Set idSet = [2L, 3L, 5L, 7L, 11L, 13L]
List accountNameList3 = AccountExample.executeQuery(
"SELECT name FROM AccountExample WHERE id IN :ids", [ids:idSet]
)
List accountNameList4 = AccountExample.executeQuery(
"SELECT name FROM AccountExample WHERE id IN (:ids)", [ids:idSet]
)
Stacktrace
Caused by ClassCastException: java.util.LinkedHashSet cannot be cast to java.lang.Long
->> 36 | unwrap in org.hibernate.type.descriptor.java.LongTypeDescriptor
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 63 | doBind in org.hibernate.type.descriptor.sql.BigIntTypeDescriptor$1
| 90 | bind . . . . . . in org.hibernate.type.descriptor.sql.BasicBinder
| 286 | nullSafeSet in org.hibernate.type.AbstractStandardBasicType
| 281 | nullSafeSet . . in ''
| 67 | bind in org.hibernate.param.NamedParameterSpecification
| 616 | bindParameterValues in org.hibernate.loader.hql.QueryLoader
| 1901 | prepareQueryStatement in org.hibernate.loader.Loader
| 1862 | executeQueryStatement in ''
| 1839 | executeQueryStatement in ''
| 910 | doQuery . . . . in ''
| 355 | doQueryAndInitializeNonLazyCollections in ''
| 2554 | doList . . . . . in ''
| 2540 | doList in ''
| 2370 | listIgnoreQueryCache in ''
| 2365 | list in ''
| 497 | list . . . . . . in org.hibernate.loader.hql.QueryLoader
| 387 | list in org.hibernate.hql.internal.ast.QueryTranslatorImpl
| 236 | performList . . in org.hibernate.engine.query.spi.HQLQueryPlan
| 1300 | list in org.hibernate.internal.SessionImpl
| 103 | list . . . . . . in org.hibernate.internal.QueryImpl
| 311 | doCall in org.grails.orm.hibernate.AbstractHibernateGormStaticApi$_executeQuery_closure12
| 196 | doExecute . . . in org.grails.orm.hibernate.GrailsHibernateTemplate
| 140 | execute in ''
| 110 | execute . . . . in ''
| 303 | executeQuery in org.grails.orm.hibernate.AbstractHibernateGormStaticApi
| 892 | executeQuery . . in org.grails.datastore.gorm.GormStaticApi
| 1026 | executeQuery in org.grails.datastore.gorm.GormEntity$Trait$Helper
Environment Information
Operating System: Windows 7 Enterprise 64-bit
Grails Version: 3.1.11
Groovy Version: 2.4.7
JVM Version: 1.8.0_102
The text was updated successfully, but these errors were encountered:
graemerocher
changed the title
Is this a bug in Grails 3.1.11? I'm using Collection Set within namedParams of executeQuery and it causes java.lang.ClassCastException
Passing a java.util.Set as a named parameter to a HQL query causes java.lang.ClassCastException
Oct 20, 2016
graemerocher
changed the title
Passing a java.util.Set as a named parameter to a HQL query causes java.lang.ClassCastException
Passing a java.util.Set as a named parameter to a HQL query causes ClassCastException
Oct 20, 2016
Issue
When trying to use Collection Set within namedParameters of ExecuteQuery It throws: java.lang.ClassCastException java.util.LinkedHashSet cannot be cast to java.lang.Long
I can convert the Collection Set to data type Collection List and it will work, but I was wondering why this was now occurring in Grails 3.1.11 when it didn't appear to occur in Grails 2.2.3 . Is this a genuine bug in Grails 3.1.11?
Expected Behaviour
ExecuteQuery handles named parameter of data type Collection Set just as it does with Collection List
Actual Behaviour
ClassCastException: java.util.LinkedHashSet cannot be cast to java.lang.Long
Example Code to Reproduce Issue
Stacktrace
Environment Information
The text was updated successfully, but these errors were encountered: