title: Hibernate: Getting Datasource from SessionFactory
body: <p>Trying get datasource from Hibernate sessionFactory so that I can pass it to flyway factory.<br/>
  Here is the code I am using:</p>
  
  <pre><code>SessionFactoryImpl factory = (SessionFactoryImpl) sessionFactory;
  ConnectionProvider provider = factory.getConnectionProvider();
  if(provider instanceof DatasourceConnectionProviderImpl) {
              System.out.println("&gt;&gt;&gt;Dude, this is hack");
  }
  </code></pre>
  
  <p>Code never prints the sysout statement.</p>
  
  <blockquote>
    <blockquote>
      <p>I am not Spring in my project, there is no way I can use <code>SessionFactoryUtils</code>.</p>
    </blockquote>
  </blockquote>