hibernate - Grails域映射异常

标签 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 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 中定义了的属性,则无需定义与另一个属性相同的属性。

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

而且它可能已经搞砸了您的数据库。尝试在数据源中以“创建”模式在新的数据库实例中运行应用程序,以创建新的新表。

谢谢。

关于hibernate - Grails域映射异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33028700/

相关文章:

hibernate - 是否可以从单个线程抛出StaleStateObjectException?

sql - 如何选择HQL中是否存在行

hibernate - 在 grails 的后台线程中调用 Hibernate

java - Getter方法使用

hibernate - Grails域delete()是否更新事务中子代的数量

hibernate - 在哪里设置 Tomcat 项目的 webservices url?

oracle - 尝试访问已收集的​​连接

hibernate - Grails 3.0.9。如何测试Hibernate二级缓存?

grails - Grails 2.5,Delete无法访问一对多关系之前

grails - grails 3 spring security用户域id字段综合