simonwillnauer wrote:
Code:
DataSourc dataSource = new DataSource(); // get it from somewhere
Session retVal = sessionFactory.openSession(dataSource.getConnection());
From Javadoc sessionFactory.openSession(dataSource.getConnection()):
Note that the second-level cache will be disabled if you supply a JDBC connection. Hibernate will not be able to track any statements you might have executed in the same transaction. Consider implementing your own ConnectionProvider.
But if you don't need second-level caching...