我有一个数据库表'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