我正在尝试将分离的条件用作“in”子句的子查询,但不知何故它不起作用:
def trades = new DetachedCriteria(Trade).build {
projections { property "tradeNbr" }
}
def activities = Activiies.withCriteria {
'in' "tradeNumber", trades
}
这是我遇到的错误:
2012-11-07 01:07:09,088 [http-bio-8081-exec-1] TRACE sql.BasicBinder - f228562 - binding parameter [1] as [INTEGER] - grails.gorm.DetachedCriteria@57c4e7b2
grails.gorm.DetachedCriteria cannot be cast to java.lang.Integer. Stacktrace follows:
java.lang.ClassCastException: grails.gorm.DetachedCriteria cannot be cast to java.lang.Integer
at grails.orm.HibernateCriteriaBuilder.invokeMethod(HibernateCriteriaBuilder.java:1587)
at org.grails.datastore.gorm.GormStaticApi.withCriteria(GormStaticApi.groovy:282)