We're updating the issue view to help you get more done. 

Use SessionFactoryServiceInitiator instead of sessionFactory.addObserver to inject SessionFactory in DatastoreProvider

Description

In Hibernate ORM, there is the notion of SessionFactory aware services (SessionFactoryServiceInitiator). We did not use it in OGM because we could not find a way to add new service initiators to the SessionFactoryServiceRegistry. Instead we used a SessionFactory observer to listen to the SessionFactory creation and use that hook to create these SF aware services.

There is a more standard way in Hibernate ORM. The trick is to override (in OgmIntegrator) SessionFactoryServiceRegistryFactoryInitiator like we do override others and change the list of services at will.

This approach will also be useful for the metamodel work.

Bonus point if we can devise an easier solution to register these SF aware ServiceInitiator. non SF aware service initiators can be registered by an Integrator implementing ServiceContributingIntegrator.
We could imagine a SessionFactoryServiceContributingIntegrator. any better solution? A potential complex point is to see if the Integrator is still around when the SesisonFactoryServiceRegistry is created.

Environment

None

Status

Assignee

Davide D'Alto

Reporter

Emmanuel Bernard

Labels

None

Worked in

None

Feedback Requested

None

Feedback Requested By

None

backPortable

None

Community Help Wanted

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

backportReEvaluate

None

Fix versions

Priority

Major