@Override public void acceptedInvite(long id) { CompanyInvite companyInvite = companyInviteDao.findUniqueBy("id", id); companyInvite.setStatus(InviteState.INVITE_ACCEPTED.getIndex()); UserCompany userCompany = new UserCompany(); userCompany.setCompanyId(companyInvite.getCompanyId()); userCompany.setUserId(companyInvite.getReceiverId()); userCompanyDao.save(userCompany); }
@Override public List<CompanyInvite> getInvitesByReceiverId(long receiverId) { StringBuilder sb = new StringBuilder(); sb.append("from CompanyInvite ci where receiverId=? and (ci.status=") .append(InviteState.INVITE_UNTREATED.getIndex()) .append(" or ") .append("ci.status=") .append(InviteState.INVITE_ACCEPTED.getIndex()) .append(")"); // String hql ="from CompanyInvite ci where receiverId=? and (ci.status=1 or ci.status=2)"; String hql = sb.toString(); return companyInviteDao.find(hql, receiverId); }