2017-03-18 38 views
0

使用舊數據庫中的表存在很多問題。 一個是名爲「角色類型」一表,有它的命名「角色類型」Grails,遺留數據庫無法獲得正確類型的ID

這裏ID是域類的重要片段:

class RoleType { 
    int roleType 
.... 
    static mapping = { 
     table 'RoleType' 
     version false 
     id column: 'roleType', type:'int', generator:'assigned' 
     roleType column: 'RoleType' 

錯誤上市:

Caused by: org.hibernate.PropertySetterAccessException: 
IllegalArgumentException occurred while calling setter for property 
[com.torntrading.legacy.RoleType.id (expected type = java.lang.Long)]; 
    target = [com.torntrading.legacy.RoleType : (unsaved)], property value = [1] 
setter of com.torntrading.legacy.RoleType.id 

我能做些什麼來解決這個問題?

回答

1

您正在爲id指定列,但不是域中的哪個屬性表示它。

id name: 'roletype', type:'int', generator:'assigned' roleType column: 'RoleType'

應該這樣做

+0

感謝的,是做到了。我是這種類型的編程新手,學習很多,而且經常混淆視聽。現在,我在同一張表中發現了一個新錯誤,但我認爲我應該在新帖子中提出這個錯誤。 – larand