Not possible to specify a SessionFactory-scoped interceptor

Description

With the new approach to instantiate a SessionFactory (i.e. ServiceRegistryBuilder -> ServicesRegistry -> MetadataSources -> Metadata -> SessionFactory) it is not possible to define a SessionFactory-scoped interceptor.

I checked the source code and it appears that an EmptyInterceptor is hard-coded.

SessionFactoryBuilderImpl:
buildSessionFactory(MetadataImplementor metadata) {
this.metadata = metadata;
options = new SessionFactoryOptionsImpl();
}

SessionFactory buildSessionFactory() {
return new SessionFactoryImpl(metadata, options, null );
}

and instantiation of class SessionFactoryOptionsImpl has usage of the EmptyInterceptor hard-coded.
In contrast, the older code directly instantiates a SessionFactoryImpl an makes use of the interceptor that is specified in the Configuration.

My recommendations:

1.) Provide a point to specify the SessionFactory-scoped interceptor where approriate (at the ServiceRegistry?)
2.) Provide SessionFactory.setInterceptor(Interceptor) - unless this would be against the idea of configuring the SessionFactory by other means before instantiation.

Environment

Hibernate ORM 4.1.0 Final (2012-02-09)
Issue is independent of OS and DB system.

Assignee

Unassigned

Reporter

Wolfram Langer

Fix versions

Labels

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure