> PurchaseOrderHeaderDto
package com.assignment.dto;
import java.util.List;
import com.assignment.entity.PurchaseItem;
public class PurchaseOrderHeaderDto{
private List<PurchaseItem> itemList;
public List<PurchaseItem> getItemList() {
return itemList;
}
public void setItemList(List<PurchaseItem> itemList) {
this.itemList = itemList;
}
public int getPonumber() {
return ponumber;
}
public void setPonumber(int ponumber) {
this.ponumber = ponumber;
}
public String getVendor() {
return vendor;
}
public void setVendor(String vendor) {
this.vendor = vendor;
}
public String getPaymentterms() {
return paymentterms;
}
public void setPaymentterms(String paymentterms) {
this.paymentterms = paymentterms;
}
public String getCompanycode() {
return companycode;
}
public void setCompanycode(String companycode) {
this.companycode = companycode;
}
private int ponumber;
private String vendor;
private String paymentterms;
private String status;
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
private String companycode;
}
above is the code for the DTO class
> PurchaseOrderHeader
package com.assignment.entity;
import java.io.Serializable;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import org.hibernate.annotations.GenericGenerator;
import com.fasterxml.jackson.annotation.JsonBackReference;
@Entity
@Table(name="PurchaseOrderHeader")
/*@FilterDef(name ="poFilter", parameters =@ParamDef(name ="ponumber", type ="int"))
@Filter(name ="poFilter", condition ="ponumber>=:ponumber")
*/
public class PurchaseOrderHeader implements Serializable{
/**
*
*/
private static final long serialVersionUID = 2293787550626038248L;
@Id
@GenericGenerator(name = "generator", strategy = "increment")
@GeneratedValue(generator = "generator")
@Column(name="ponumber")
private int ponumber;
@JsonBackReference
@OneToMany( fetch = FetchType.EAGER,mappedBy = "purchaseorder",cascade = CascadeType.ALL)
private List<PurchaseItem> itemList;
public List<PurchaseItem> getItemList() {
return itemList;
}
public int getPonumber() {
return ponumber;
}
public void setPonumber(int ponumber) {
this.ponumber = ponumber;
}
public void setItemList(List<PurchaseItem> itemList) {
this.itemList = itemList;
}
public Integer getCompanycode() {
return companycode;
}
public void setCompanycode(Integer companycode)
{
this.companycode = companycode;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getVendor() {
return vendor;
}
public void setVendor(String vendor) {
this.vendor = vendor;
}
public String getPaymentterms() {
return paymentterms;
}
public void setPaymentterms(String paymentterms) {
this.paymentterms = paymentterms;
}
@Column(name="companycode")
private Integer companycode;
@Column(name="status")
private String status;
@Column(name="vendor")
private String vendor;
@Column(name="paymentterms")
private String paymentterms;
public PurchaseOrderHeader() {
}
public PurchaseOrderHeader(int ponumber, Integer companycode, String status, String vendor, String paymentterms) {
this.ponumber = ponumber;
this.companycode = companycode;
this.status = status;
this.vendor = vendor;
this.paymentterms = paymentterms;
}
}
выше - код для класса DO
model mapper mapping errors ,Unable to convert String to Integer
DTO class has company code as String and the DO class has the company code
as Integer type when data is passed in json if string value is passed
for company code it should throw 400 bad request error in postman.
NumberFormatException при передаче данных в почтальоне.
База данных Mysql, используемая для транзакций БД.
SEVERE: Servlet.service () для сервлета [spring] в контексте с путем [/ Pro] вызвала исключение [Ошибка обработки запроса; вложенное исключение - org.modelmapper.MappingException: ошибки отображения ModelMapper:
1) Converter org.modelmapper.internal.converter.NumberConverter@6279a752 failed to convert java.lang.String to java.lang.Integer.
1 error] with root cause
java.lang.NumberFormatException: For input string: "asdfghertyu"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)