使用插件项目域类从主项目映射域类时Hibernate映射异常

时间:2013-05-27 10:49:04

标签: hibernate grails

我创建了一个包含几个域类(UserRoleUserRole等等的插件项目。)我可以从主项目中访问这些域类。

当我尝试在主项目中使用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

0 个答案:

没有答案