我有一個數據庫表'MyTable',它在更新字段'Status'時具有觸發器。EJB3.0更新表中具有相同值的字段
下面是我想要做一個假碼:
MyTable table = new Mytable();
table.setTableId(1);
table.setStatus ("NEW");
em.persist (table); //At this point the trigger did not kick in since this inserted a new record
...
MyTable table2 = em.find(MyTable.class, 1);
table2.setStatus ("NEW");
em.merge(table2)//Even though im updating the record with the same status with the same value, i still want the trigger to kick. However the trigger is not being activated.
...
MyTable table3 = em.find(MyTable.class, 1);
table3.setStatus ("OLD");
em.merge(table3)//The trigger is being activated here since the status is different the status value when it was inserted the first time.
長話短說,我怎樣才能做到「transfer2」的變化觸發更新,即使狀態一樣?
-Thanks
你好,問題是在同一個事務中還有其他操作。因此,我希望能夠在發生錯誤時回滾所有數據庫操作,因此提交事務不是一個選項。 – Brams 2012-08-17 07:56:42