public List<EmailRecieverEventCategory> findByPersonId(int perId) {
   List<EmailRecieverEventCategory> aListEmailR = new ArrayList<EmailRecieverEventCategory>();
   aListEmailR =
       getHibernateTemplate().find("from EmailRecieverEventCategory where UserId = ?", perId);
   for (Iterator<EmailRecieverEventCategory> it = aListEmailR.iterator(); it.hasNext(); ) {
     EmailRecieverEventCategory emailRecieverEventCategory = it.next();
     HibernateUtils.initialize(emailRecieverEventCategory.getCategory());
   }
   return aListEmailR;
 }
 public List<String> findEmailByCategoryId(int catId) {
   List<String> aListEmail = new ArrayList<String>();
   List<EmailRecieverEventCategory> aList =
       getHibernateTemplate().find("from EmailRecieverEventCategory where CatID = ?", catId);
   for (Iterator<EmailRecieverEventCategory> it = aList.iterator(); it.hasNext(); ) {
     EmailRecieverEventCategory emailRecieverEventCategory = it.next();
     HibernateUtils.initialize(emailRecieverEventCategory.getPerson());
   }
   for (Iterator<EmailRecieverEventCategory> it = aList.iterator(); it.hasNext(); ) {
     EmailRecieverEventCategory emailRecieverEventCategory = it.next();
     aListEmail.add(emailRecieverEventCategory.getPerson().getEmail());
   }
   System.out.println("Length Send Email: " + aListEmail.size());
   return aListEmail;
 }
 public boolean saveEmailReciver(List<EmailRecieverEventCategory> aList) {
   try {
     if (aList.size() >= 1) {
       EmailRecieverEventCategory ec = aList.get(0);
       List<EmailRecieverEventCategory> aListRemove =
           getHibernateTemplate()
               .find(
                   "from EmailRecieverEventCategory where UserId = ?",
                   ec.getPerson().getPersonId());
       getHibernateTemplate().deleteAll(aListRemove);
     }
     getHibernateTemplate().saveOrUpdateAll(aList);
     return true;
   } catch (Exception e) {
     flag = false;
   }
   return flag;
 }