2015-10-09 67 views
0

運行正常後,我的應用程序開始在啓動時給我奇怪的域錯誤。無論我做什麼,我都無法得到這個工作。Grails域映射例外

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

卸下屬於實體關係不改變錯誤消息。有沒有人看過這個錯誤?

+0

你能嘗試在新的數據庫實例中創建嗎? – Neoryder

+0

根據我的經驗,如果你有一個'belongsTo'中定義的實體,你不必另外明確地定義它。如果你在'EntityHistory'域中保留了'Entity entity',你只需要聲明'belongsTo = Entity'。如果你刪除了'Entity entity',你可以保留'belongsTo = [entity:Entity]'。但是,由於您已經說刪除'belongsTo'完全不能解決問題,因此這可能沒有幫助。 – Rob

+1

_running fine_和_strange域錯誤_之間發生了什麼? –

回答

0

我想如果你已經在界定產權屬於關聯EntityHistory那麼沒有必要定義相同的其他屬性。

因此請嘗試從EntityHistory類中刪除實體實體,因爲它無法將數據庫中的列與相同的名稱屬性進行映射。

另外它可能已經搞砸了你的數據庫。嘗試在DataSource中使用「創建」模式在新數據庫實例中運行應用程序以創建新的新表。

謝謝。