我在现有的Grails 1.3.7项目中创建了一个新的域对象。
package com.xfitlog
class Implement {
String name
String description
String abbreviation
static belongsTo = [exercise : Exercise]
static constraints = {
name( nullable: false, unique: true )
description( nullable: false, maxSize: 2000 )
abbreviation( nullable: true )
}
String toString() {
"${name}"
}
}
此课程链接到“实施”课程。
class Exercise{
String name
String description
boolean isApproved
Implement implement
static constraints = {
name ( nullable: false )
description ( nullable: false, maxSize: 5000 )
isApproved ( nullable: true )
implement ( nullable: true )
}
String toString() {
"${name}"
}
}
当我通过windows命令提示符运行grails run-app时,我收到以下错误:
引起:org.springframework.beans.factory.BeanCreationException: 创建名为'transactionManager'的bean时出错:无法解析 在设置bean属性时引用bean'sessionFactory' essionFactory“;嵌套异常是 org.springframework.beans.factory.BeanCreationException:错误 创建名为'sessionFactory'的bean:调用init方法 失败;嵌套异常是org.h ibernate.MappingException:An 表练习中的关联是指未映射的类: com.xfitlog.Implement ... 28更多引起:org.springframework.beans.factory.BeanCreationException:错误 创建名为'sessionFactory'的bean:调用init方法 失败;嵌套异常是org.hibernate.MappingException:An 表练习中的关联是指未映射的类: com.xfitlog.Implement ... 28更多引起:org.hibernate.MappingException:表练习中的关联引用了未映射的类: com.xfitlog.Implement ... 28更多应用程序上下文关闭...
我尝试过创建一个新项目并添加这些相同的域类,一切正常。我不知道我的原始项目发生了什么变化,但有些事情搞砸了。
感谢您的帮助。
答案 0 :(得分:0)
确保您没有将hibernate hbm.xml类与域对象混合使用。我遇到了类似的错误,结果证明这是个问题。
我当前的应用程序混合旧样式groovy pojo(基本上是一个用groovy编写的java pojo),使用库中的hiberate映射文件和主项目中的域类。
还要确保所有域类都具有正确的import和package语句。