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; }