2

我创建了一个带有几个域类(、、、等)的插件项目,User并且RoleUserRole能够从主项目访问这些域类。

当我尝试将User域类与JobInfo主项目中的域类映射时,出现映射异常。

两个域类之间的映射:
这个域类在主项目中:

class JobInfo { 
  String jobName  
  String jobOutput  
  User submittedByUser

  static constraints = {  
      jobName(nullable:false, maxSize:255)  
      jobOutput(nullable:true,type:"text")  
      submittedByUser (nullable:true)    
  } 

  static mapping = {  
    version false  
  }  

}

这个域类在插件项目中:

class User { 
    String username 
    String email 
    String firstname 
    String lastname 
    String password 
    boolean enabled 
    boolean accountExpired 
    boolean accountLocked 
    boolean passwordExpired 


    static constraints = { 
            username(unique:true) 
            password blank: false 
            email email: true, blank: false,unique:true 
    } 

    static mapping = { 
            password column: 'password' 
            datasource "auth" 
            version false   
    } 

}

我得到以下映射异常:

013-05-27/14:57:51.622 [localhost-startStop-1]  ERROR context.GrailsContextLoader - Error executing bootstraps: 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: An association from the table job_info refers to an unmapped class: com.test.domain.User 
org.springframework.beans.factory.BeanCreationException: 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: An association from the table job_info refers to an unmapped class: com.test.domain.User** 
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) 
        at java.util.concurrent.FutureTask.run(FutureTask.java:138) 
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895) 
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918) 
        at java.lang.Thread.run(Thread.java:662) 
Caused by: 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: An association from the table job_info refers to an unmapped class: com.test.domain.User
        ... 5 more 
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.MappingException: An association from the table job_info refers to an unmapped class: com.test.domain.User 
        ... 5 more 
Caused by: org.hibernate.MappingException: An association from the table job_info refers to an unmapped class: com.test.domain.User 
        ... 5 mor
4

0 回答 0