01: package com.technoetic.xplanner.domain.repository;
02:
03: import java.util.Iterator;
04: import java.util.List;
05:
06: import net.sf.hibernate.Hibernate;
07: import net.sf.hibernate.HibernateException;
08:
09: import com.technoetic.xplanner.domain.Role;
10:
11: public class RoleRepositoryImpl extends HibernateObjectRepository
12: implements RoleRepository {
13: public RoleRepositoryImpl() throws HibernateException {
14: super (Role.class);
15: }
16:
17: public Role findRoleByName(String rolename)
18: throws RepositoryException {
19: List roles = null;
20: roles = getHibernateTemplate().find(
21: "from role in class " + Role.class.getName()
22: + " where role.name = ?", rolename,
23: Hibernate.STRING);
24: Role role = null;
25: Iterator roleIterator = roles.iterator();
26: if (roleIterator.hasNext()) {
27: role = (Role) roleIterator.next();
28: }
29: return role;
30: }
31: }
|