2015-01-12 3 views
0

작동하지 내가 가진 :GORM 복합 매핑 데이터베이스와 Grails의 2.4.3과 PostgreSQL에

class ClassA { 
    Set classB = [] 

    static belongsTo = [classC: ClassC] 
    static hasMany = [classB: ClassB] 
} 

과 :

@EqualsAndHashCode 
class ClassB implements Serializable { 

    ClassA classA 
    Integer number 

    static belongsTo = [classA: ClassA] 

    static mapping = { 
    id composite: ['number', 'classA'] 
} 

그리고 나는이 이상한 오류 받고 있어요 :

[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 

무슨 일 이니? 내가 뭘 잘못하고 있니?

답변

0
메시지가 무엇을 의미하는지 확실하지

, 그러나 이것은 잘못된 것입니다 :

Set ClassB = [] 

이 있어야한다

Set<ClassB> classB = new HashSet<>() 

UPDATE :

the refdoc를 참조하십시오. 필드는 내가 말하고자하는 원시 타입이어야한다. ClassB가 인스턴스에서 속성을 추출 변환

시도 :

@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'] 
    } 
} 
+0

질문에 잘못 쓴, 나는 실제 코드에 확인했다, 그것은 문제가되지 않습니다. –

+0

ClassA에도'@ EqualsAndHashCode'를 적용 해보세요. – injecteer

+0

'Serializable을 구현하는 것과하지 않고 동일한 것' –