I wrote a program in netbeans on hibernate framework to persist my data in mysql db, Everything is going fine, the main is arising when I am using the snippet session.save(newcustomer);
session--object of Session. newcustomer-- object of entity class.
Sample Snippet--
public tab_customer create(tab_customer newCustomer) {
Transaction transaction = session.beginTransaction();
transaction.begin();
System.out.println(transaction.isActive());
session.save(newCustomer);
transaction.commit();
return newCustomer;
}
Its throwing error can anyone help me pl开发者_高级运维ease.
It seems to me that you begin two transactions. Comment out transaction.begin();
.
精彩评论