Hibernate Grails域映射异常

Hibernate Grails域映射异常,hibernate,grails,gorm,grails-domain-class,Hibernate,Grails,Gorm,Grails Domain Class,运行正常后,我的应用程序开始在启动时给我奇怪的域错误。不管我做什么,我都不能让它工作 Caused by MappingException: Could not determine type for: appospherelaunchv1.Entity, at table: entity_history, for columns: [org.hibernate.mapping.Column(entity)] 实体历史类: class EntityHistory { Entity

运行正常后,我的应用程序开始在启动时给我奇怪的域错误。不管我做什么,我都不能让它工作

Caused by MappingException: Could not determine type for: appospherelaunchv1.Entity, at table: entity_history, for columns: [org.hibernate.mapping.Column(entity)]
实体历史类:

    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
        }
}

删除“属于”实体关系不会更改错误消息。以前有人看到过这个错误吗?

我想如果您已经在EntityHistory的belongsTo中定义了属性,那么就不需要将其定义为另一个属性

所以,请尝试从EntityHistory类中删除实体,因为它无法将同名属性映射到数据库中的列

而且它可能已经破坏了你的数据库。尝试在DataSource中以“create”模式在新的DB实例中运行应用程序,以创建新的表


谢谢。

您能尝试在新的数据库实例中创建吗?根据我的经验,如果您在
中定义了实体,那么您也不必单独明确定义它。如果在
实体历史记录
域中保留
实体
,则只需声明
belongsTo=Entity
。如果删除
实体
,则可以保留
belongsTo=[Entity:Entity]
。但是,既然您已经说过,完全删除
属性到
并不能纠正问题,这可能没有什么帮助。在正常运行和奇怪的域错误之间发生了什么?