简体   繁体   English

hibernate拦截器帖子保存?

[英]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, 我需要在hibernate中拦截一个实体的post save,但是我发现的所有内容都是在save上,在保存之前处理实体,并且有一个postFlush方法返回一个巨大的懒惰迭代器,我无法理解使用它,请建议我在hibernate保存或更新后捕获实体的方法,

Regards, 问候,

postFlush is what you want. postFlush是你想要的。 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. 在数据库中执行sql之后调用它。

Try the javax.persistance.PostPersist annotation: 尝试javax.persistance.PostPersist注释:

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

Well I guess you are looking for the SaveOrUpdateEventListener interface. 好吧,我想你正在寻找SaveOrUpdateEventListener接口。

(Here is a reference of the Hibernate event system .) (这是Hibernate事件系统的参考。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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