这是实体类,我只是想保存这个实体,但当我试图点击api时,我得到了如下所示的错误,我非常确定这是由于一些Map问题,非常感谢任何帮助:-
@Entity
@Table(name = "productpurchasedata")
public class Test {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "customerid")
private int customerid;
@Column(name = "name")
private String name;
@Column(name = "mailid")
private String mailid;
@Column(name = "address")
private String address;
@Column(name = "city")
private String city;
@Column(name = "state")
private String state;
@Column(name = "postalcode")
private String postalcode;
@Column(name = "mobileno")
private long mobileno;
@ManyToOne(targetEntity = Test.class, fetch = FetchType.LAZY,optional = false)
@JoinColumns({ @JoinColumn(name = "customerid", referencedColumnName = "customerid", insertable=false, updatable=false) })
private PurchaseDetails purchasedetails;
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, targetEntity = Test.class)
@JoinColumn(name = "customerid")
private List<ProductPurchased> productpurchased;
@ManyToOne(targetEntity = Test.class, fetch = FetchType.LAZY,optional = false)
@JoinColumns({ @JoinColumn(name = "customerid", referencedColumnName = "customerid", insertable=false, updatable=false) })
private PaymentHistory paymenthistory;
错误:
"message": "Error accessing field [private int com.bhushan.spring.files.excel.model.Test.customerid] by reflection for persistent property [com.bhushan.spring.files.excel.model.Test#customerid] : com.bhushan.spring.files.excel.model.PaymentHistory@7659b9; nested exception is org.hibernate.property.access.spi.PropertyAccessException: Error accessing field [private int com.bhushan.spring.files.excel.model.Test.customerid] by reflection for persistent property [com.bhushan.spring.files.excel.model.Test#customerid] : com.bhushan.spring.files.excel.model.PaymentHistory@7659b9",
1条答案
按热度按时间czfnxgou1#
我想你们的关系看起来是错的。因为一个用户有许多付款历史记录和购买细节,而不是相反。许多用户没有相同的历史记录。