ImmutableOrderInterceptor: how is it attached to orders?

I can’t find any reference (static or via XML configuration or annotations) to this class. But Hibernate still executes it when saving an order. Is it by convention (because it contains the word “Order”) ? However it seems to be executed no matter the entity (TestOrder, OrderType, GlobalProperty…). I’d like to put some Order-specific logic there.

It’s autowired in the HibernateSessionFactoryBean.interceptors field.

1 Like

Thanks Rafal. If there is no way to attach an interceptor to a single persistent class, I prefer the listeners model.

Also, the parameters in onFlushDirty are not very convenient (arrays). Ideally it should have both versions of the entity, like a database trigger.