简体   繁体   中英

hibernate interceptor post save?

i need to intercept post save for an entity in hibernate, but all what i found was on save, which is dealing with the entity before being saved, and there's a postFlush method which return a huge lazy iterator, that i can't understand how to use it, please suggest me a way to catch entity after hibernate save or update,

Regards,

postFlush is what you want. The iterator will let you loop through all of the entities that were inserted or updated. It gets called after the sql has executed in the database.

Try the javax.persistance.PostPersist annotation:

@PostPersist
private void postPersist()
{
    // do stuff
}

Well I guess you are looking for the SaveOrUpdateEventListener interface.

(Here is a reference of the Hibernate event system .)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM