开发者

Perform some common stuff when commiting into 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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜