【发布时间】:2015-10-09 01:56:00
【问题描述】:
运行良好后,我的应用程序在启动时开始出现奇怪的域错误。无论我做什么,我都无法让它发挥作用。
Caused by MappingException: Could not determine type for: appospherelaunchv1.Entity, at table: entity_history, for columns: [org.hibernate.mapping.Column(entity)]
EntityHistory 类:
class EntityHistory {
Entity entity
Date startDate
Date endDate
Boolean isCurrent
Date changeDate
static belongsTo = [entity: Entity]
static constraints = {
entityTypeID nullable:false
startDate nullable:false
endDate nullable:true
changeDate nullable:false
isCurrent nullable:true
}
}
实体类:
class Entity {
String description
Date changeDate
Date createDate
Date entityChangeDate
EntityTypes entityTypes
User user
Customer customer
Contacts contacts
LeadSources leadSources
EntityStatus entityStatus
static hasMany = [entityData: EntityData]
static belongsTo = [entityTypes: EntityTypes, user: User, customer: Customer, contacts: Contacts, leadSources: LeadSources, entityStatus: EntityStatus]
static constraints = {
user nullable:false
customer nullable:false
contacts nullable:false
leadSources nullable:false
description size:1..2000, nullable:true
entityTypes nullable:false
changeDate nullable:false
createDate nullable:false
entityStatus nullable: false
}
}
删除属于实体关系不会更改错误消息。有没有人见过这个错误?
【问题讨论】:
-
您可以尝试在新的数据库实例中创建吗?
-
根据我的经验,如果您在
belongsTo中定义了实体,您也不必单独显式定义它。如果您将Entity entity保留在您的EntityHistory域中,则只需声明belongsTo = Entity。如果您删除Entity entity,您可以保留belongsTo = [entity: Entity]。但是,既然您说完全删除belongsTo并不能解决问题,这可能没有帮助。 -
运行良好和奇怪的域错误之间发生了什么?
标签: hibernate grails grails-orm grails-domain-class