我创建了一个包含几个域类(User
,Role
,UserRole
等等的插件项目。)我可以从主项目中访问这些域类。
当我尝试在主项目中使用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