John__wang 2015-06-12 01:54
浏览 720

grails Domain属性名与GORM API方法名相 冲突

环境:win7 + intellij13 + grails2.2.3
一个已有项目有下面一个domain
class AxisType extends ScalarType {
...
String first
String last
...

static constraints = {
    ...
    first nullable: true
    last nullable: true
}

}
在项目启动时报下面的错误信息:

org.codehaus.groovy.grails.web.context.GrailsContextLoader Error initializing the application: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.codehaus.groovy.runtime.InvokerInvocationException: groovy.lang.MissingMethodException: No signature of method: com.alu.ud.pm.common.AxisType.first() is applicable for argument types: () values: []

Possible solutions: first(), first(), first(), first(java.lang.String), first(java.util.Map), first(java.lang.String)

从错误信息上看,grails 把domain的属性first当成了GROM api里的first()方法来处理了,初步估计domain的属性名不能和GORM API方法名(如last, first, fistAll)重复。
但是在新建一个helloworld去验证这个问题的时候

class AxisType {
String first
String last
static constraints = {
first(nullable:true)
last(nullable:true)
}
}
helloworld工程启动成功,访问 anAxisTypeObject.first, AxisType.first()方法时都很正常,不会相互影响。

感觉问题好诡异,哪位大神能来给解释一下这是什么情况?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 素材场景中光线烘焙后灯光失效
    • ¥15 请教一下各位,为什么我这个没有实现模拟点击
    • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
    • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 保护模式-系统加载-段寄存器