2

問題: ExecuteQuery の namedParameters 内でコレクション セットを使用しようとすると、次がスローされます: java.lang.ClassCastException java.util.LinkedHashSet を java.lang.Long にキャストできません

Set をデータ型 List に変換できますが、Grails 2.2.3 では発生していないように見えたのに、なぜ Grails 3.1.11 で発生しているのか疑問に思っていました。これは Grails 3.1.11 の本当のバグですか?

// A Mocked up Domain
class AccountExample {
   Long id
   String name
}
//Code that works
List idList = [2L, 3L, 5L, 7L, 11L, 13L]
List accountNameList  = 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 accountNameList  = AccountExample.executeQuery(
   "SELECT name FROM AccountExample WHERE id IN :ids",
   [ids:idSet]
)

スタック トレースの一部

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
4

2 に答える 2