2013-11-22 42 views
1

我收到以下錯誤,當我試圖創建靜態腳手架新員工:grails 2.3.1批量更新從update [0]返回了意外的行計數;實際行數:0;預計:1

錯誤500:內部服務器錯誤

URI /文件跟蹤器/員工/保存類 org.hibernate.StaleStateException消息 批更新返回來自update [0]的意外行計數;實際行數:0;預計:1

圍繞線 38的grails-app /控制器/組織/ simpragma/EmployeeController.groovy

圍繞PageFragmentCachingFilter.java

什麼是錯的191線?

package org.xyz 

class Employee { 
    String name; 
    String department; 
    String role; 
    String userId; 
    String pw; 

    static mapping = { 
     table 'employee' 
     version false 
     id name: 'userId' 
     id generator: 'native' 
    } 

    static hasMany = [toAllocations: Allocation, fromAllocations: Allocation] 

    static mappedBy = [toAllocations: 'toEmployee', fromAllocations: 'fromEmployee'] 
    static constraints = { 
     department nullable : true 
      role nullable : true  
    } 
} 

package org.xyz 

class Allocation { 

    static hasOne = [file:File, toEmployee:Employee, fromEmployee:Employee, remark:Remark] 
    static mappedBy = [toEmployee: 'toAllocations', fromEmployee: 'fromAllocations' ] 

    static constraints = { 
     remark nullable: true 
    } 
} 

package org.xyz 

class File { 
    String fileNumber; 
    Date requestedDate; 
    String requestedBy; 
    String priority; 
    Double budget; 
    String requestedByDepartment; 
    String subject; 

    static mapping = { 
     id name: 'fileNumber' 
     version false 
     id generator: 'native' 
    } 
    static hasMany = [allocations: Allocation] 
    static constraints = { 
     fileNumber nullable : true 
     priority nullable : true 
     budget nullable : true 
    } 
} 

package org.xyz 

class Remark { 
    String remark; 
    Date remarkDate; 

    static belongsTo = [allocation: Allocation]; 
    static constraints = { 
    } 
} 

回答

0

在我的情況下,出於測試目的,我試圖將自己的id分配給對象。我不能這樣做,如果id應該在保存期間生成。

相關問題