public TemplateData findTemplateByName(String name) throws HibernateException {
   Session session = HibernateSessionFactory.currentSession();
   Transaction transaction = session.beginTransaction();
   Criteria criteria = session.createCriteria(TemplateData.class);
   criteria.add(Expression.eq("name", name));
   criteria.setMaxResults(1);
   TemplateData result = (TemplateData) criteria.uniqueResult();
   transaction.commit();
   HibernateSessionFactory.closeSession();
   return result;
 }
 public TemplateData loadByResourceKey(String key) throws HibernateException {
   Session session = HibernateSessionFactory.currentSession();
   Transaction transaction = session.beginTransaction();
   Criteria criteria = session.createCriteria(TemplateData.class);
   criteria.add(Expression.eq("resourceKey", key));
   criteria.setMaxResults(1);
   TemplateData result = (TemplateData) criteria.uniqueResult();
   transaction.commit();
   HibernateSessionFactory.closeSession();
   return result;
 }
예제 #3
0
 public Person findPersonByEmail(String emailAddress) throws HibernateException {
   Session session = HibernateSessionFactory.currentSession();
   Transaction transaction = session.beginTransaction();
   Criteria criteria = session.createCriteria(Person.class);
   // criteria.createAlias("emailAddesses", "email");
   criteria.add(Expression.eq("emailAddress", emailAddress));
   // criteria.add(Expression.like("realname", personalName,
   // MatchMode.ANYWHERE));
   criteria.setMaxResults(1);
   Person person = (Person) criteria.uniqueResult();
   transaction.commit();
   HibernateSessionFactory.closeSession();
   return person;
 }
예제 #4
0
 public Person authenticatePerson(String username, char[] password) throws HibernateException {
   Session session = HibernateSessionFactory.currentSession();
   Transaction transaction = session.beginTransaction();
   Criteria criteria = session.createCriteria(Person.class);
   criteria.add(Expression.eq("username", username));
   criteria.setMaxResults(1);
   Person person = (Person) criteria.uniqueResult();
   transaction.commit();
   HibernateSessionFactory.closeSession();
   logger.debug("Found person: " + person.getUsername());
   if (person.checkPlainPassword(new String(password))) {
     return person;
   }
   return null;
 }
예제 #5
0
 @SuppressWarnings("unchecked")
 public Person loadPersonForPrincipal(Principal principal) throws HibernateException {
   // Principal principal = request.getUserPrincipal();
   Session session = HibernateSessionFactory.currentSession();
   Transaction transaction = session.beginTransaction();
   Criteria criteria = session.createCriteria(Person.class);
   criteria.add(Expression.eq("username", principal.getName()));
   criteria.setMaxResults(1);
   List<Person> personList = criteria.list();
   Person person = null;
   if (personList.size() == 1) {
     person = personList.get(0);
   }
   transaction.commit();
   HibernateSessionFactory.closeSession();
   return person;
 }