When implementing an org.hibernate.integrator.spi.Integrator
for hibernate 4.3, one gets a Configuration
, SessionFactoryImplementor
and SessionFactoryServiceRegistry
object.
One way to fetch the metadata is to obtain a connection provider:
sessionFactory.getJdbcServices().getConnectionProvider()
But getConnectionProvider()
is deprecated and does not work for a multi tenant setup.
Javadocs say
Access to connections via
org.hibernate.engine.jdbc.spi.JdbcConnectionAccess
should be preferred over access viaConnectionProvider
, whenever possible.
But my problem is, that I don't find a way to obtain a JdbcConnectionAccess
. It would be possible to use the given SessionFactoryServiceRegistry
and replicate the code from SessionFactoryImpl#buildLocalConnectionAccess()
, but that is not a nice solution.
What is the recommended way to fetch a connection in an Integrator
?