2
我想「在」子句中使用一個分離標準作爲子查詢,但不知它不工作:使用的DetachedCriteria的子查詢條款
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] - [email protected]
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)
detachedCriteria的文檔說,list()是一個默認的方法,但顯然它沒有這樣做。我期待「印刷行業」獲得交易,但它會打印對象參考。難道我做錯了什麼? – rks