log4j:WARN No appenders could be found for logger (org.hibernate.cfg.annotations.Version).
log4j:WARN Please initialize the log4j system properly.
Hibernate: insert into purchase_details (date, total_quantity, total_weight, type) values (?, ?, ?, ?)
HE:org.hibernate.exception.GenericJDBCException: could not insert: [com.focus.beans.PurchaseDetailsList]
Table created, but the values are not inserted into the tables… How can I solve this?
package com.focus.beans;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import lombok.Getter;
import lombok.Setter;
@Entity
@Table(name = "purchase_details")
public class PurchaseDetailsList {
@Id @GeneratedValue
@Column (name="type_id")
@Getter @Setter private String type_id;
@Column (name = "type")
@Getter @Setter private String type;
@Column(name = "date")
@Getter @Setter private String date;
@Column (name = "total_quantity")
@Getter @Setter private String totalquantity;
@Column (name = "total_weight")
@Getter @Setter private String totalweight;
}
This is my bean class… The table is created and it is redirected to the next page, but the values we entered in are not inserted into the database.
MyController.class
package com.focus.controller;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.focus.beans.PurchaseDetailsList;
import com.focus.dao.Dao;
public class PurchaseDetail extends HttpServlet {
private static final long serialVersionUID = 1L;
PrintWriter out = null;
boolean flag;
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
Dao dao = Dao.getInstance();
PurchaseDetailsList pdl = new PurchaseDetailsList();
pdl.setType(request.getParameter("types"));
pdl.setDate(request.getParameter("date"));
pdl.setTotalquantity(request.getParameter("totalquantity"));
pdl.setTotalweight(request.getParameter("totalweight"));
//System.out.println("Am arun");
flag = dao.persist(pdl);
response.getWriter();
response.sendRedirect("JSP/PurchaseDetailsListForm.jsp");
}
}
But the given values are not inserted into the table, and an exception is thrown:
org.hibernate.exception.GenericJDBCException: could not insert:
How can I fix it?