This is my entity class , which I am using to save the details of customer along with the purchase detail and product purchased and payment module , Its finely saving in DB but while retrieving getting result as null .
@Entity
@Table(name = "productpurchasedata")
public class Test {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int customerid;
@ManyToOne(cascade = { CascadeType.ALL })
@JoinColumn(name = "customerid", insertable = false, updatable = false)
private CustomerProductSave customerProductSave;
@ManyToOne(cascade = { CascadeType.ALL })
@JoinColumn(name = "customerid", insertable = false, updatable = false)
private PurchaseDetails purchasedetails;
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@JoinColumn(name = "customerid")
private List<ProductPurchased> productpurchased;
@ManyToOne(cascade = { CascadeType.ALL })
@JoinColumn(name = "customerid", insertable = false, updatable = false)
private PaymentHistory paymenthistory;
Here I am able to save the data which result in something like this :-
{
"customerid": 1,
"customerProductSave": {
"customerids": 2,
"name": "nitesh",
"mailid": "niteshbhushan95@gmail.com",
"address": "hyd",
"city": "telanagana",
"state": "telanagana",
"postalcode": "847226",
"mobileno": 6300769631
},
"purchasedetails": {
"purchasedate": "22-07-2021",
"modeofpayment": "paytm",
"emiapplicable": false,
"totalamount": 21000,
"purchaseId": 4
},
"productpurchased": [
{
"purchaseid": 5,
"purchaseamount": 2000,
"purchasedproductid": 1,
"productquantity": 0
},
{
"purchaseid": 6,
"purchaseamount": 2000,
"purchasedproductid": 1,
"productquantity": 0
}
],
"paymenthistory": {
"transactionid": 3,
"paymentstatus": "paid"
}
}
Now when I am trying to retrieve the data by customerid it is not accepting , it giving message as null , I am not pretty much may be some mistake in mapping
尝试使用 fetch = FetchType.EAGER 而不是 fetch = FetchType.LAZY 在所有映射购买细节和产品购买和支付模块
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.