How could I obtain the connection provider from a session factory in hibernate 5? The method to obtain the connection does not exist anymore and is not replaced by anything in the javadocs. This code snippet worked in 4.1, but in 5.1 it does not (specifically, getConnectionProvider() does not exist).
private SessionFactory factory;
private ServletOutputStream outputStream;
private ServletContext context;
public Object execute(Map properties) {
InputStream input = null;
try {
Session session = factory.getCurrentSession();
SessionFactoryImplementor sessionFactoryImplementation = (SessionFactoryImplementor) session.getSessionFactory();
ConnectionProvider connectionProvider = sessionFactoryImplementation).getConnectionProvider();
Connection conn = connectionProvider.getConnection();