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;
/**
* 缴款单
* @Author lbc
* @Date 9:12 2022/5/19
**/
@Getter
@Setter
@Entity
@Table(name = "TB_FL_SETTLE")
@RepositoryBean("FLSettleSumInfoRepository")
public class FLSettleSumInfo extends BaseFkBill implements Serializable {
/**
* 协议类型(0是地采1是集采)
*/
private String PactType;
/**
* 单据日期,缴款、欠款、还款的日期
*/
private Date BillDate;
/**
* 采购人ID
*/
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<FLSettleDetailInfo> 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<FLDiscountUsedInfo> 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> 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;
/**
* 缴款单/欠款单/还款单 子表
* @Author lbc
* @Date 9:21 2022/5/20
**/
@Getter
@Setter
@Entity
@Table(name = "TB_FL_Settle_Detail")
public class FLSettleDetailInfo extends BaseEntity implements Serializable {
private String branchId;
/// <summary>
/// 政策ID
/// </summary>
private String PolicyId;
/// <summary>
/// 欠款单ID,还款单用,还的哪个欠款单
/// </summary>
private String DebtId;
/// <summary>
/// 金额
/// </summary>
private BigDecimal Amount;
private String GroupNumberGuid;
@ManyToOne(targetEntity = FLSettleSumInfo.class)
@JoinColumn(name = "fk", referencedColumnName = "pk"/*updatable = true,insertable = true*/)
@ChangedIgnore
@JSONField(serialize = false)//nested exception is java.lang.StackOverflowError
@JsonIgnore
private FLSettleSumInfo flSettleSumInfo;
}
2056

被折叠的 条评论
为什么被折叠?



