Link to home
Start Free TrialLog in
Avatar of Omer-Pitou
Omer-Pitou

asked on

Hibernate 5.1: Is a way to get a connection

Hi,
Is there a way to get a connection from Hibernate 5.1 session object?
I am looking forward to hearing from you.
ASKER CERTIFIED SOLUTION
Avatar of Am P
Am P
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Omer-Pitou
Omer-Pitou

ASKER

Hi
What I wanted was to get a Connection from the pool maintained by Hibernate, for my jasperreporats and some key Stored procedures I  was running with createSQLQuery. With this, I had the impression I was loosing some performance yield by prepared callable statement.
Then, I found this
HibernateUtil.getSessionFactory().getCurrentSession().doWork(new Work() {
              @Override
              public void execute(Connection connection) throws SQLException {
                   if (call == null) {
                       String sql = "";
                       call = connection.prepareCall(sql);
                   }
                   
                }
            });