grails:org.hibernate.MappingException:关联引用未映射类:java.util.Set
有人熟悉以下错误吗? 我将Hibernate4+与Grails2.4.4一起使用 这是整个错误日志:grails:org.hibernate.MappingException:关联引用未映射类:java.util.Set,hibernate,grails,gorm,Hibernate,Grails,Gorm,有人熟悉以下错误吗? 我将Hibernate4+与Grails2.4.4一起使用 这是整个错误日志: |Loading Grails 2.4.4 |Configuring classpath . |Environment set to development ................................. |Packaging Grails application ........... |Compiling 1 source files ..................
|Loading Grails 2.4.4
|Configuring classpath
.
|Environment set to development
.................................
|Packaging Grails application
...........
|Compiling 1 source files
.........................
|Running Grails application
Error |
2015-03-19 16:54:11,496 [localhost-startStop-1] ERROR context.GrailsContextLoaderListener - 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.hibernate.MappingException: Association references unmapped class: java.util.Set
Message: 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.hibernate.MappingException: Association references unmapped class: java.util.Set
Line | Method
->> 266 | run in java.util.concurrent.FutureTask
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 1142 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 617 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 745 | run in java.lang.Thread
Caused by 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.hibernate.MappingException: Association references unmapped class: java.util.Set
->> 266 | run in java.util.concurrent.FutureTask
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 1142 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 617 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 745 | run in java.lang.Thread
Caused by BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.MappingException: Association references unmapped class: java.util.Set
->> 266 | run in java.util.concurrent.FutureTask
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 1142 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 617 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 745 | run in java.lang.Thread
Caused by MappingException: Association references unmapped class: java.util.Set
->> 266 | run in java.util.concurrent.FutureTask
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 1142 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 617 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 745 | run in java.lang.Thread
Error |
Forked Grails VM exited with error
问题是:
- 我的一个域类包含了一个大写字母,它不应该在其中(‘利用’而不是‘利用’)
package core
class Scenario {
String name
static belongsTo = [ Exploit ]
static hasMany = [ Exploits : Exploit ]
static constraints = {
name nullable: false , maxSize: 32
}
}
新代码:
package core
class Scenario {
String name
static belongsTo = [ Exploit ]
static hasMany = [ exploits : Exploit ]
static constraints = {
name nullable: false , maxSize: 32
}
}
它起作用了 如果在嵌入式对象中使用类似hasMany的集合,也会出现此错误 复合元素不能包含嵌套集合 “复合元素”与@Embeddeble对象相同。因此,@embeddeble对象的集合不可能包含集合。它们必须升级为@Entity对象
请参阅在将项目从Grails2.3.11升级到2.5.4之后,我遇到了同样的问题。事实证明,必须更新的是spring安全性生成的类User、Role和UserRole。它们有过时的getter和setter,现在被解释为bean属性。我得到了类似的异常,但命名是正确的 问题是有两个数据源使用-用于读取和写入副本 此问题的修复程序添加了以下内容:
static mapping = {
datasource 'ALL'
}