0
我是JPA的新手,在過去兩天中遇到此問題。每當我嘗試更新數據庫中的對象時,合併查詢都會執行兩次,並且數據不會在數據庫中更新。任何人都可以告訴我我犯了什麼錯誤。面對JPA合併問題。合併操作不反映在數據庫中,查詢正在執行兩次
這裏是摘錄:
Employee emp = em.find(Employee.class,empid);
if (emp != null) {
emp.setDescription("Success");
emp.setDob(new Timestamp(new Date().getTime()));
etxn = em.getTransaction();
etxn.begin();
em.merge(emp);
System.out.println(em.merge(emp));
etxn.commit();
}