Skip to content

Instantly share code, notes, and snippets.

@jgoldberg
Created April 27, 2011 21:07
Show Gist options
  • Select an option

  • Save jgoldberg/945214 to your computer and use it in GitHub Desktop.

Select an option

Save jgoldberg/945214 to your computer and use it in GitHub Desktop.
Creating a BaseDAO class which supports both Hibernate Template + JDBC Template + Simple JDBC Template
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.simple.SimpleJdbcTemplate;
import org.springframework.orm.hibernate3.SessionFactoryUtils;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
/**
* @author jgoldberg
*
*/
public class BaseDaoImpl extends HibernateDaoSupport {
public SimpleJdbcTemplate getSimpleJdbcTemplate() {
return new SimpleJdbcTemplate(SessionFactoryUtils.getDataSource(getSessionFactory()));
}
public JdbcTemplate getJdbcTemplate() {
return new JdbcTemplate(SessionFactoryUtils.getDataSource(getSessionFactory()));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment