在hibernate中更新记录时是否必须编写session.update(employee)
?
这是我的代码。
public void updateEmployee() {
Session session = HibernateUtil.getSessionFactory().openSession();
Transaction transaction = null;
try {
transaction = session.beginTransaction();
Employee employee = (Employee)session.get(Employee.class, 113);
employee.setName("Prakash1");
employee.setSal(60008);
//session.update(employee);
transaction.commit();
System.out.println("Employee records updated!");
} catch (HibernateException e) {
transaction.rollback();
e.printStackTrace();
} finally {
session.close();
}
}