org.appfuse.dao.hibernate.RoleDaoHibernate 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 java.util.List;
import org.appfuse.dao.RoleDao;
import org.appfuse.model.Role;
/**
* This class interacts with Spring's HibernateTemplate to save/delete and
* retrieve Role objects.
*
* @author Bryan Noll
*/
public class RoleDaoHibernate extends GenericDaoHibernate implements RoleDao {
public RoleDaoHibernate() {
super(Role.class);
}
public Role getRoleByName(String rolename) {
List roles = getHibernateTemplate().find("from Role where name=?", rolename);
if (roles.isEmpty()) {
return null;
} else {
return (Role) roles.get(0);
}
}
public void removeRole(String rolename) {
Object role = getRoleByName(rolename);
getHibernateTemplate().delete(role);
}
}