I have two spring beans - one is my custom event listener implementing three interfaces, second is Hibernate integrator implementation that registers these listeners.
In case when I CustomFlushListener implements three interfaces, how to register it properly?
I have other CustomUpdateEcentListener that implements PostUpdateEventListener and this is easy - I just register it as below, what about CustomFlushListener? Do I have to register it three times - once per each interface, how should it look like?
**Spring Bean:**
Code:
public class CustomFlushListener implements FlushEventListener, FlushEntityEventListener, AutoFlushEventListener{
....
}
**Integrator Bean:**
Code:
public class HbCustomIntegrator implements Integrator {
private static final Logger LOG = Logger.getLogger(HbCustomIntegrator.class);
PostUpdateEventListener postUpdateEventListener;
@Override
public void integrate(Metadata metadata, SessionFactoryImplementor sessionFactoryImplementor, SessionFactoryServiceRegistry sessionFactoryServiceRegistry) {
final EventListenerRegistry eventRegistry = sessionFactoryServiceRegistry.getService(EventListenerRegistry.class);
LOG.info("Registering event listeners");
eventRegistry.appendListeners(POST_UPDATE, postUpdateEventListener);
eventRegistry.appendListeners(FLUSH, ????);
eventRegistry.appendListeners(FLUSH_ENTITY, ????);
}
@Override
public void disintegrate(SessionFactoryImplementor sessionFactoryImplementor, SessionFactoryServiceRegistry sessionFactoryServiceRegistry) {
}