Mysql 如何从拦截器获取新创建的实体id

Mysql 如何从拦截器获取新创建的实体id,mysql,hibernate,Mysql,Hibernate,我正在扩展hibernate EmptyInterceptor,我想记录一个新创建的实体id。在onSave方法中,我得到的实体没有自动生成的id。我能做什么?APIEmptyInterceptor: boolean onSave(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types) 因此,您可以通过参数获取id。我目前正在使用onSave,但在一个新实体中,id为null。

我正在扩展hibernate EmptyInterceptor,我想记录一个新创建的实体id。在onSave方法中,我得到的实体没有自动生成的id。我能做什么?

API
EmptyInterceptor

boolean onSave(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types) 

因此,您可以通过参数获取id。

我目前正在使用onSave,但在一个新实体中,id为null。您是使用
对象实体
参数还是
可序列化id
参数?您确定调用了
拦截器