Grails域映射异常

时间:2015-10-09 01:56:00

标签: 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)]

EntityHistory Class:

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

删除所属实体关系不会更改错误消息。有没有人见过这个错误?

1 个答案:

答案 0 :(得分:0)

我想如果您已经在 EntityHistory belongsTo 中定义属性,则无需将其定义为与其他属性相同。

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

它也可能已经搞砸了你的数据库。尝试使用" create"在新的数据库实例中运行您的应用程序。 DataSource中的模式用于创建新的新表。

感谢。