Grails GORM复合映射不工作
在grails 2.4.3和postgresql上作为数据库,我有:Grails GORM复合映射不工作,grails,gorm,composite-key,Grails,Gorm,Composite Key,在grails 2.4.3和postgresql上作为数据库,我有: class ClassA { Set classB = [] static belongsTo = [classC: ClassC] static hasMany = [classB: ClassB] } 以及: 我得到了一个奇怪的错误: [localhost-startStop-1] ERROR context.GrailsContextLoaderListener - Error initial
class ClassA {
Set classB = []
static belongsTo = [classC: ClassC]
static hasMany = [classB: ClassB]
}
以及:
我得到了一个奇怪的错误:
[localhost-startStop-1] ERROR context.GrailsContextLoaderListener - Error initializin
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
java.lang.NullPointerException 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
java.lang.NullPointerException 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
发生了什么事?我做错了什么?不确定消息的意思,但这是错误的:
Set ClassB = []
应该是
Set<ClassB> classB = new HashSet<>()
在这个问题上写错了,我在实际代码上还可以,这不是问题所在。尝试将@EqualsAndHashCode应用于ClassA,以及同样的事情,包括和不包括“implements Serializable”,谢谢帮助人员,但仍然给我相同的神秘错误。尝试逐个排除域类以三角化问题。也许它位于其他地方>
Set<ClassB> classB = new HashSet<>()
@EqualsAndHashCode
class ClassB implements Serializable {
ClassA classA
String someAProp
Integer number
void setClassA( ClassA a ){
classA = a
someAProp = a.someProp
}
static belongsTo = [classA: ClassA]
static mapping = {
id composite: ['number', 'someAProp']
}
}