I am getting below error while working on the Hibernate code to insert record in the database. Please suggest what wrong I am doing here. Hibernate: insert into feedback (fb_rating_id, fb_suggestion, fb_topic_id, user_info) values (?, ?, ?, ?) Exception deleting record :org.hibernate.exception.GenericJDBCException: could not insert: [com.tdp.model.Feedback]
public int insertFeedback(String ratingId, String msg) {
int status = 0;
Session sess = sessionFactory.openSession();
Transaction tx = null;
try {
tx = sess.beginTransaction();
//Criteria crit = sess.createCriteria(Feedback.class);
// crit.add(Restrictions.eq("feedbackId",feedback.getFeedbackId()));
Feedback fbObj = new Feedback();
fbObj.setFbRatingId(Integer.parseInt(ratingId));
fbObj.setFbSuggestion(msg);
fbObj.setFbTopicId(null);
fbObj.setUserInfo("");
sess.save(fbObj);
tx.commit();
status = 1;
} catch (HibernateException e) {
System.out.println("Exception deleting record :" + e);
if (tx != null) {
tx.rollback();
}
} finally {
sess.close();
}
return status;
}
Feedback.java
@Table(name=TDPConstants.FEEDBACK )
public class Feedback {
private Integer feedbackId; //primary key
private Integer fbRatingId;
private Integer fbTopicId;
private String fbSuggestion ;
private String userInfo ;
@Id
@Column(name = "feedback_id",unique = true, nullable = false)
@GeneratedValue(strategy = GenerationType.AUTO)
public Integer getFeedbackId() {
return feedbackId;
}
public void setFeedbackId(Integer feedbackId) {
this.feedbackId = feedbackId;
}
//all other setters & getters