BriteSnow / snow

A Lightweight, Google Guice, Simple, and Powerful Web Application Framework that makes building modern Web Application a breeze! Fully open source, Apache V2 licensed.
http://britesnow.com/snow
29 stars 10 forks source link

Remove daoHelper.executeSQL and .getConnection are they are not safe in Hibernate anymore #23

Closed jeremychone closed 11 years ago

jeremychone commented 11 years ago

In Hibernate 4.x deprecated getConnectionProvider is deprecated, and using the JDBC connection as such create memory leaks. So, removing these two level API from the HibernateDaoHelper.

Developers should use HQL as much as possible (with the HibernateDaoHelper.executeHql), or use the Session.doWork method bellow to do the low level work (see below).

jeremychone commented 11 years ago

The right way to do some lowlevel JDBC work would be using the Session.doWork.

http://stackoverflow.com/questions/3526556/session-connection-deprecated-on-hibernate

session.doWork(
    new Work() {
        public void execute(Connection connection) throws SQLException 
        { 
            doSomething(connection); 
        }
    }
);
jeremychone commented 11 years ago

Done, available from 2.0.1-SNAPSHOT