【问题标题】:grails 2.3.1 Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1grails 2.3.1 批量更新从更新 [0] 返回了意外的行数;实际行数:0;预期:1
【发布时间】:2013-11-22 08:34:07
【问题描述】:

当我尝试在静态脚手架中创建新员工时出现以下错误:

错误 500:内部服务器错误

URI /file-tracker/employee/save 类 org.hibernate.StaleStateException 消息 批量更新从更新 [0] 返回了意外的行数;实际行数:0;预计:1

第 38 行左右 grails-app/controllers/org/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 = {
    }
}

【问题讨论】:

    标签: grails


    【解决方案1】:

    就我而言,出于测试目的,我试图将自己的 id 分配给对象。如果在保存期间应该生成 id,我不能这样做。

    【讨论】:

      猜你喜欢
      • 2020-09-27
      • 2011-04-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-11
      • 2021-04-24
      相关资源
      最近更新 更多