栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

Row was updated or deleted by another transaction or unsaved-value mapping was incorrect解决

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Row was updated or deleted by another transaction or unsaved-value mapping was incorrect解决

Row was updated or deleted by another transaction or unsaved-value mapping was incorrect 记录报错

使用jpa进行update时错误
fk为外键
我的问题处在 ,子对象里面fk不为0 jpa会报Row was updated or deleted by another transaction or unsaved-value mapping was incorrect
将jpa 子对象 fk 置0

2.客户端传入的对象中 version 与 数据库中的version 需要一致

下面继承 自己封装的

package com.jzt.fl.upstream.basic.contracts.entity;

import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.jzt.fl.basic.biz.exSystemProxy.PushBillDto;
import com.jzt.wotu.data.annotation.Cascade;
import com.jzt.wotu.data.annotation.ChangedIgnore;
import com.jzt.wotu.data.jpa.annotation.RepositoryBean;
import fl.common.entity.BaseBill;
import fl.common.entity.BaseFkBill;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import javax.persistence.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;


@Getter
@Setter
@Entity
@Table(name = "TB_FL_SETTLE")
@RepositoryBean("FLSettleSumInfoRepository")
public class FLSettleSumInfo extends BaseFkBill implements Serializable {

    
    private  String PactType;

   
    
    private Date BillDate;
    
    private  String PurchaserId;
    
    //采购人名称
    private  String Purchaser;
    
    // 实际缴款单位ID
    private  String ActPayId;
    
    //实际缴款单位
    private  String ActPayName;
    
    //缴款人
    private  String ActPayPerson;
    
    //收取形式,见收取形式字典
    private  String PayWay;
    
    //收取形式,见收取形式字典
       // [LookupQuery("JZTFL.Common.Shared.Interfaces.ILookupQueryService, JZTFL.Common.Shared.Interfaces",
                             //"GetDictItemName", "PayWay", "CollectType")]
   @Transient
    private  String PayWayName;
    
    //金额
    private BigDecimal PayAmount;
    
    //票折单号
    private  String Bill2No;
    
    //票折票号
    private  String InvoiceNo;
    
    //实收类型ID
    private  String ActIncomeTypeId;
    
    //	实收类型
       // [LookupQuery("JZTFL.Common.Shared.Interfaces.ILookupQueryService, JZTFL.Common.Shared.Interfaces",
                             //"GetDictItemName", "ActIncomeTypeId", "DraftItemType")]
    @Transient
    private  String ActIncomeTypeName;
    
    //有无折扣证明,1是,0否,默认0
    private  Integer IsEvidence;
    
    //开票项目ID
    private  String InvoiceProjId;
    
    //	开票项目ID
       // [LookupQuery("JZTFL.Common.Shared.Interfaces.ILookupQueryService, JZTFL.Common.Shared.Interfaces",
                             //"GetDictItemName", "InvoiceProjId", "DraftItemType")]
    @Transient
    private  String InvoiceProjName;
    
    //票据类型
    private  String InvoiceType;
    
    //票据类型
    @Transient
    private  String InvoiceTypeName;
    
    //缴税标识
    private  String TaxIdentify;
    
    //	缴税标识
    @Transient
    private  String TaxIdentifyName;
    
    //凭证号
    private  String CertNo;
    
    //预计还款日,还款单用
    private  Date PrercvDate;
    
    //是否收入,1是,0否
    private  Integer IsIncome;
    
    //是否提成,1是,0否
    private  Integer IsRoyalty;
    
    //单据类型,1:缴款单,2:欠款单,3、还款单,4:预收单,5、预收分配单
    private  Integer BillType;
    
    //是否转实收,0:没有,1:已转实收,默认0.欠款单不允许转实收
    private  Integer ToIncome;
    
    //明细
    @Fetch(FetchMode.JOIN)
    @OneToMany(mappedBy = "flSettleSumInfo", cascade = CascadeType.ALL, fetch = FetchType.EAGER, orphanRemoval = true)
    @Cascade
    private Set FLSettleDetailInfos = new HashSet<>();

    //操作人
    private  String LastmodifyId;

    //操作人名称
    private  String LastmodifyName;

    
    //欠款单ID,还款单用,还的哪个欠款单
    private  String DebtId;

   @Fetch(FetchMode.JOIN)
   @OneToMany(mappedBy = "settleSumInfo", cascade = CascadeType.ALL, fetch = FetchType.EAGER, orphanRemoval = true)
   @Cascade
    private  Set FLDiscountUsedInfos = new HashSet<>();

    //       // [LookupQuery("JZTFL.Common.Shared.Interfaces.ILookupQueryService, JZTFL.Common.Shared.Interfaces",
//                             //"GetPactValueByFileName", "FK", "PactYear")]
    @Transient
    private String PactYear;
    // [LookupQuery("JZTFL.Common.Shared.Interfaces.ILookupQueryService, JZTFL.Common.Shared.Interfaces",
    //"GetPactValueByFileName", "FK", "PactBillId")]
    @Transient
    private String PactBillId;
    // [LookupQuery("JZTFL.Common.Shared.Interfaces.ILookupQueryService, JZTFL.Common.Shared.Interfaces",
    //"GetPactValueByFileName", "FK", "CustNo")]
    @Transient
    private String CustNo;
    // [LookupQuery("JZTFL.Common.Shared.Interfaces.ILookupQueryService, JZTFL.Common.Shared.Interfaces",
    //"GetPactValueByFileName", "FK", "CustName")]
    @Transient
    private String CustName;
    // [LookupQuery("JZTFL.Common.Shared.Interfaces.ILookupQueryService, JZTFL.Common.Shared.Interfaces",
    //"GetPactValueByFileName", "FK", "CustID")]
    @Transient
    private String PactCustID;
    // [LookupQuery("JZTFL.Common.Shared.Interfaces.ILookupQueryService, JZTFL.Common.Shared.Interfaces",
    //"GetPactValueByFileName", "FK", "PactPurchaser")]
    @Transient
    private String PactPurchaser;
    // [LookupQuery("JZTFL.Common.Shared.Interfaces.ILookupQueryService, JZTFL.Common.Shared.Interfaces",
    //"GetPactValueByFileName", "FK", "PactPurchaserId")]
    @Transient
    private String PactPurchaserId;
    // [LookupQuery("JZTFL.Common.Shared.Interfaces.ILookupQueryService, JZTFL.Common.Shared.Interfaces",
    //"GetOrganizationNameByBranch", "BranchID")]
    @Transient
    private String OrgName;

    private  String IsOk;
    private  String IsOkNote;

    @Transient
    private List pushBillDto;


 @Override
 public void fixRelation() {
  super.fixRelation();
  for (FLSettleDetailInfo flSettleDetailInfo : FLSettleDetailInfos) {

   flSettleDetailInfo.setFlSettleSumInfo(this);

  }
  for (FLDiscountUsedInfo flDiscountUsedInfo : FLDiscountUsedInfos) {
   flDiscountUsedInfo.setSettleSumInfo(this);
  }
 }


 @Override
 public void fixBillID(String billID) {

  super.fixBillID(billID);

 }

 @Override
 public void softDelete(int flag) {
  super.softDelete(flag);

  for (FLSettleDetailInfo flSettleDetailInfo : FLSettleDetailInfos) {

   flSettleDetailInfo.setDeleteFlag(flag);

  }
  for (FLDiscountUsedInfo flDiscountUsedInfo : FLDiscountUsedInfos) {

   flDiscountUsedInfo.setDeleteFlag(flag);

  }

 }


}

子对象

package com.jzt.fl.upstream.basic.contracts.entity;

import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.jzt.wotu.data.annotation.ChangedIgnore;
import fl.common.entity.BaseEntity;
import fl.common.entity.BaseFkEntity;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Objects;


@Getter
@Setter
@Entity
@Table(name = "TB_FL_Settle_Detail")
public class FLSettleDetailInfo extends BaseEntity implements Serializable {

    private String branchId;
    
    /// 
    ///	政策ID
    /// 
    private  String PolicyId;
    /// 
    ///	欠款单ID,还款单用,还的哪个欠款单
    /// 
    private  String DebtId;
    /// 
    ///	金额
    /// 
    private BigDecimal Amount;

    private  String GroupNumberGuid;

    @ManyToOne(targetEntity = FLSettleSumInfo.class)
    @JoinColumn(name = "fk", referencedColumnName = "pk")
    @ChangedIgnore
    @JSONField(serialize = false)//nested exception is java.lang.StackOverflowError
    @JsonIgnore
    private FLSettleSumInfo flSettleSumInfo;

}

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/1021108.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号