[hibernate-dev] Interceptors and dependency injection

Steve Ebersole steve at hibernate.org
Thu Dec 14 07:25:47 EST 2017

https://hibernate.atlassian.net/browse/HHH-11259 lists some other
possibilities for things we might consider for accessing through
ManagedBeanRegistry.  We discussed Interceptor in Paris - I can definitely
see that with some caveats/restrictions.  Add it to that list or create a
new sub-task.

As for chaining Interceptors, I guess it depends how that is exposed.  E.g.
a comma-separated list in settings would inherently imply ordering.  That
works for SessionFactory-scoped Interceptors.  I'm not sure we need a
composite though wrapping the individual Interceptors, a List<Interceptor>
would suffice and save some memory (granted a tiny amount).  For
Session-scoped Interceptors we would need to account for a few things, but
its certainly possible.  Supposing there are also SessionFactory-scoped

   1. How would a user indicate that the Session-scoped Interceptors should
   replace the SessionFactory-scoped ones versus adding to them.  What's the
   ordering there - SessionFactory-scoped Interceptors first?  Or
   SessionScoped ones>
   2. How would a user indicate that a Session should have no
   Interceptors?  That is a common requirement.
   3. Probably some others I am not thinking of.

On Thu, Dec 14, 2017 at 2:44 AM Guillaume Smet <guillaume.smet at gmail.com>

> Hi all (and Steve especially as it seems you are working on the
> subject right now),
> You talking about CDI made me think of something we did at
> $previousJob a long time ago.
> I didn't quite follow what you did in 6 about CDI/Spring injection but
> basically the requirement was to be able to create Spring managed
> interceptors and to inject them in the PersistenceProvider.
> At the time, we ended up with the following:
> https://github.com/openwide-java/owsi-core-parent/blob/master/owsi-core/owsi-core-components/owsi-core-component-jpa/src/main/java/fr/openwide/core/jpa/hibernate/ejb/InterceptorAwareHibernatePersistenceProvider.java
> But I think it would probably be nice if we could inject them directly.
> Another thing we did which is not really related is creating a
> ChainedInterceptor to be able to define several interceptors (the idea
> was that we did want the ability to enable some interceptors at will
> depending on what a given application required).
> Just injecting the interceptors in a random order would probably not
> do it as I think you will probably want to define them in an ordered
> way.
> Not sure it's useful but I thought I might as well talk about it now
> that you are working on this feature.
> Have a nice day.
> --
> Guillaume
> _______________________________________________
> hibernate-dev mailing list
> hibernate-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/hibernate-dev

More information about the hibernate-dev mailing list