Grails 控制器类中的 HQL 查询导致 ClassCastException?
我最困惑的是。我有一个非常简单的查询。
def value = Contribution.executeQuery(
'select sum(c.balance) from Contribution c where
c.account.id=:accountId', [accountId: memberInstance?.account?.id])
我尽我所能地进行了交互式调试 - 所需的实例都不为空(memberInstance、memberInstance.account)。但产生的错误是ClassCastException?
Stacktrace follows:
java.lang.ClassCastException: com.myapp.contribution.ContributionService cannot be cast to com.myapp.contribution.ContributionService
at com.myapp.contribution.ContributionService$$FastClassByCGLIB$$d800d90.invoke(<generated>) ...
有没有人知道为什么生成 CCE,以及为什么类类型不能转换为自身(无论如何,我不明白为什么 grails 应该这样做?)
谢谢!
亚历克斯
I am most perplexed. I have a very simple query.
def value = Contribution.executeQuery(
'select sum(c.balance) from Contribution c where
c.account.id=:accountId', [accountId: memberInstance?.account?.id])
I interactively debugged as well as I could - none of the instances required are null (memberInstance, memberInstance.account). But the resulting error is a ClassCastException?
Stacktrace follows:
java.lang.ClassCastException: com.myapp.contribution.ContributionService cannot be cast to com.myapp.contribution.ContributionService
at com.myapp.contribution.ContributionService$FastClassByCGLIB$d800d90.invoke(<generated>) ...
Does anyone have any clues as to why a CCE is being generated, an furthermore, why a class type could not be cast to itself (anyway, not that I understand why grails should be doing this?)
THANK YOU!
Alexx
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的 - 如果我将“def value”更改为“Double value”并将“[0]”附加到查询行的末尾(以获取返回的数组中的第一个值,这是缺失的部分之一),那么这作品。
CCE 非常具有误导性...
OK - if I change "def value" to "Double value" and append "[0]" to the end of the query line (to get the first value in the array returned, which was one of the missing pieces), then this works.
The CCE was very misleading...