我想问一下Hibernate Interceptor和Events在性能方面是否有区别?
让我们将这两个考虑在内:
INTERCEPTOR
public class MyInterceptor extends EmptyInterceptor {
@Override
public boolean onSave(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types) {
//something done here
}
}
LISTENER
public class MyEventListener implements PreInsertEventListener {
@Override
public boolean onPreInsert(PreInsertEvent preInsertEvent) {
//same thing here
}
}
假设我对两者都可以做同样的事情。就性能而言,我应该选择哪一个?
谢谢。