org.appfuse.dao.hibernate.LookupDaoHibernate Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of appfuse-hibernate Show documentation
Show all versions of appfuse-hibernate Show documentation
AppFuse DAO backend implemented with Hibernate (http://hibernate.org).
package org.appfuse.dao.hibernate;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.appfuse.dao.LookupDao;
import org.appfuse.model.Role;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import java.util.List;
import org.hibernate.Session;
/**
* Hibernate implementation of LookupDao.
*
* @author Matt Raible
* Modified by jgarcia: updated to hibernate 4
*/
@Repository
public class LookupDaoHibernate implements LookupDao {
private Log log = LogFactory.getLog(LookupDaoHibernate.class);
private final SessionFactory sessionFactory;
/**
* Initialize LookupDaoHibernate with Hibernate SessionFactory.
* @param sessionFactory
*/
@Autowired
public LookupDaoHibernate(final SessionFactory sessionFactory) {
this.sessionFactory = sessionFactory;
}
/**
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
public List getRoles() {
log.debug("Retrieving all role names...");
Session session = sessionFactory.getCurrentSession();
return session.createCriteria(Role.class).list();
}
}