开发者

Perform some common stuff when commiting into database

开发者 https://www.devze.com 2023-03-15 00:56 出处:网络
I am using hibernate as ORM tool, i want to perform some common stuff for all the entities that i flush into the database.

I am using hibernate as ORM tool, i want to perform some common stuff for all the entities that i flush into the database.

Currently , whenever i save object into database, i perforrm following steps :-

  1. Open session
  2. Begin a Transaction
  3. Create Te Object
  4. save the object using session.save(object);
  5. commit the transaction if save is successfull. otherwise rollback transasction.
  6. close the session.

Now, i want to perform some post-save and pre-flush ch开发者_StackOverflow中文版ecks, is there any way to do so.

Thanks.


You can implement 'preFlush' method of Interceptor. Check this for hibernate interceptor.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号