जैसा कि टिप्पणियों में चर्चा की गई है, आप अपने कोड को अपेक्षित रूप से काम करने के लिए नीचे के रूप में संशोधित कर सकते हैं।
MarketPrice.java
@Entity
@Table(name = "MarketPrice")
public class MarketPrice {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "itemId")
private Long itemId;
@Column(name = "analysisDate")
private Date analysisDate;
@Column(name = "marketName")
private String marketName;
@Column(name = "category")
private String category;
@Column(name = "marketPlace")
private String marketPlace;
@Column(name = "state")
private String state;
@Column(name = "district")
private String district;
@Transient
public Items currentItem;
@Column(name = "itemName")
public String getItemName() {
return this.currentItem.itemName;
}
@Column(name = "unitofPrice")
public String getUnitofPrice() {
return this.currentItem.unitofPrice;
}
@Column(name = "minimumPrice",columnDefinition = "Float(10,2)")
public Float getMinimumPrice() {
return this.currentItem.minimumPrice;
}
@Column(name = "maximumPrice",columnDefinition = "Float(10,2)")
public Float getMaximumPrice() {
return this.currentItem.maximumPrice;
}
@Transient
public ArrayList<Items> marketPrices;
Items.java
public class Items implements Serializable {
private static final long serialVersionUID = -2428562977284114465L;
@Id
@Column(name="id")
private int id;
public String itemName;
public String unitofPrice;
public Float minimumPrice;
public Float maximumPrice;
DAO.java
public String saveListOfMarketPrice(MarketPrice marketPrice) {
System.out.println("In Analyser DAO fro bulk saving");
final Session session = getSession();
session.beginTransaction();
for (Items item : marketPrice.marketPrices) {
marketPrice.currentItem = item;
session.save(marketPrice);
}
session.getTransaction().commit();
session.close();
return "success";
}