jpa 2.0 - jpa @postpersist @postupdate only after transaction commit -
i'm inserting/updating 3 tables while using manual transaction. want insert history table right after transaction commited. means there 3 em.persist
actions (for each table), , after commiting them call method.
this code:
@resource private ejbcontext context; public void save(object obj) { try { transaction = context.getusertransaction(); transaction.begin(); em.persist(obj); sb2.save(obj); //persist in sb2 sb3.save(obj); //persist in sb2 transaction.commit(); } catch (exception exp) { transaction.rollback(); } }
is there kind of post commit method? how can call method after commit , , not after persist ?
thank's in advance.
jpa not provide such events, eclipselink provides extended events through sessioneventlistener api.
http://eclipse.org/eclipselink/documentation/2.5/jpa/extensions/p_session_event_listener.htm
you consider container jta events.
Comments
Post a Comment