问题
my entity class is mentioned below:-
public class ExportOrderInfo implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Column(name = "CURRENT_ORDER_NUMBER")
private Integer currentOrderNumber;
@Id
@Column(name = "ORG_CODE")
private Integer orgCode;
@Id
@Column(name = "STIR_CD")
private Integer stirCd;
@Id
@Column(name = "EXPIRE_DATE")
private Date expireDate;
@Column(name = "ENTERPRISE_CODE", insertable = false, updatable = false)
private Integer enterpriseCode;
@Column(name = "ORG_NAME", insertable = false, updatable = false)
private String orgName;
@Column(name = "TOTAL_PREV", insertable = false, updatable = false)
private Double totalPrev;
@Column(name = "ENTERPRISE_NAME", insertable = false, updatable = false)
private String enterpriseName;
@Column(name = "GG_EMP_CODE", insertable = false, updatable = false)
private Integer ggEmpCode;
@Column(name = "GG_FIRST_NAME", insertable = false, updatable = false)
private String ggFirstName;
@Column(name = "GG_LAST_NAME", insertable = false, updatable = false)
private String ggLastName;
@Column(name = "CNTN_EMP_CODE", insertable = false, updatable = false)
private Integer cntnEmpCode;
@Column(name = "CNTN_FIRST_NAME", insertable = false, updatable = false)
private String cntnFirstName;
@Column(name = "CNTN_LAST_NAME", insertable = false, updatable = false)
private String cntnLastName;
@Column(name = "GVP_EMP_CODE", insertable = false, updatable = false)
private Integer gvpEmpCode;
@Column(name = "GVP_FIRST_NAME", insertable = false, updatable = false)
private String gvpFirstName;
@Column(name = "GVP_LAST_NAME", insertable = false, updatable = false)
private String gvpLastName;
@Column(name = "RVP_EMP_CODE", insertable = false, updatable = false)
private Integer rvpEmpCode;
@Column(name = "RVP_FIRST_NAME", insertable = false, updatable = false)
private String rvpFirstName;
@Column(name = "RVP_LAST_NAME", insertable = false, updatable = false)
private String rvpLastName;
@Column(name = "AVP_EMP_CODE", insertable = false, updatable = false)
private Integer avpEmpCode;
@Column(name = "AVP_FIRST_NAME", insertable = false, updatable = false)
private String avpFirstName;
@Column(name = "AVP_LAST_NAME", insertable = false, updatable = false)
private String avpLastName;
@Column(name = "AM_EMP_CODE", insertable = false, updatable = false)
private Integer amEmpCode;
@Column(name = "AM_FIRST_NAME", insertable = false, updatable = false)
private String amFirstName;
@Column(name = "AM_LAST_NAME", insertable = false, updatable = false)
private String amLastName;
@Column(name = "TM_EMP_CODE", insertable = false, updatable = false)
private Integer tmEmpCode;
@Column(name = "TM_FIRST_NAME", insertable = false, updatable = false)
private String tmFirstName;
@Column(name = "TM_LAST_NAME", insertable = false, updatable = false)
private String tmLastName;
@Column(name = "AE_EMP_CODE", insertable = false, updatable = false)
private Integer aeEmpCode;
@Column(name = "AE_FIRST_NAME", insertable = false, updatable = false)
private String aeFirstName;
@Column(name = "AE_LAST_NAME", insertable = false, updatable = false)
private String aeLastName;
@Column(name = "MULTI_YEAR_FLAG", insertable = false, updatable = false)
private String multiYearFlag;
@Column(name = "MULTI_YEAR_IN", insertable = false, updatable = false)
private Integer multiYearIn;
@Column(name = "MULTI_YEAR_LENGTH", insertable = false, updatable = false)
private Integer multYearLength;
@Column(name = "OPTY_ID", insertable = false, updatable = false)
private String optyId;
@Column(name = "OPTY_NAME", insertable = false, updatable = false)
private String optyName;
@Column(name = "OVERALL_RG", insertable = false, updatable = false)
private String overallRg;
@Column(name = "ITEM_STATUS", insertable = false, updatable = false)
private String itemStatus;
@Column(name = "EBS_ACCT_ID", insertable = false, updatable = false)
private String ebsAcctId;
@Column(name = "FST_YR_CLIENT_FLG", insertable = false, updatable = false)
private String firstYrClientFlag;
@Column(name = "PRODUCT_LOB", insertable = false, updatable = false)
private String productLob;
@OneToOne
@NotFound(action = NotFoundAction.IGNORE)
@Cascade(org.hibernate.annotations.CascadeType.ALL)
@JoinColumn(name = "CURRENT_ORDER_NUMBER")
@JoinColumn(name = "EXPIRE_DATE")
@JoinColumn(name = "ORG_CODE")
@JoinColumn(name = "STIR_CD")
private ExportOrderDetailInfo orderDetail;
@OneToOne
@NotFound(action = NotFoundAction.IGNORE)
@Cascade(org.hibernate.annotations.CascadeType.ALL)
@JoinColumn(name = "OPTY_ID", referencedColumnName = "OPTY_ID")
private OrderDownload orderDownload;
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
ExportOrderInfo that = (ExportOrderInfo) o;
if (!currentOrderNumber.equals(that.currentOrderNumber)) {
return false;
}
if (!orgCode.equals(that.orgCode)) {
return false;
}
if (!Objects.equals(stirCd, that.stirCd)) {
return false;
}
return Objects.equals(expireDate, that.expireDate);
}
@Override
public int hashCode() {
int result = currentOrderNumber.hashCode();
result = 31 * result + orgCode.hashCode();
result = 31 * result + (stirCd != null ? stirCd.hashCode() : 0);
result = 31 * result + (expireDate != null ? expireDate.hashCode() : 0);
return result;
}
}
public class OrderDownload implements Serializable {
private static final long serialVersionUID = 3838097352824067548L;
@Id
@Column(name = "UD_ID")
private String udId;
@Column(name = "DWN_REQ_DT")
private Date dwnReqDt;
@Column(name = "DWN_STATUS")
private String dwnStatus;
@Column(name = "OPTY_ID")
private String optyId;
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
OrderDownload that = (OrderDownload) o;
return udId.equals(that.udId);
}
@Override
public int hashCode() {
return udId.hashCode();
}
}
and there is a toPredicate() in Specification class as mention below:-
public Predicate toPredicate(Root<ExportOrderInfo> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder builder) {
if(beginningOfQuarter != null && endOfQuarter != null){
criteriaQuery.distinct(true);
root.join("orderDetail", JoinType.LEFT);
root.join("orderDownload", JoinType.INNER);
return builder.and(builder.equal(root.<String>get(randomColumnName), valueToSearchFor) , builder.isNotNull(root.get("optyId")));
}else{
criteriaQuery.distinct(true);
root.fetch("orderDetail", JoinType.LEFT);
root.fetch("orderDownload", JoinType.LEFT);
return builder.and(builder.equal(root.<String>get(randomColumnName), valueToSearchFor));
}
}
}
i'm getting its works but i got org.springframework.orm.jpa.JpaSystemException: More than one row with the given identifier was found: OrderDownload(udId=null, dwnReqDt=null, dwnStatus=null, optyId=1-7RV24-105)
来源:https://stackoverflow.com/questions/55158314/its-works-but-i-got-org-springframework-orm-jpa-jpasystemexception-more-than-on