List of usage examples for org.hibernate Query setComment
Query<R> setComment(String comment);
From source file:org.zanata.dao.LocaleMemberDAO.java
License:Open Source License
@SuppressWarnings("unchecked") public List<HLocaleMember> findAllByLocale(LocaleId localeId) { Query query = getSession().createQuery( "from HLocaleMember as m where m.id.supportedLanguage.localeId = :localeId order by lower(m.id.person.name)"); query.setParameter("localeId", localeId); query.setComment("LocaleMemberDAO.findAllByLocale"); return query.list(); }
From source file:org.zanata.dao.LocaleMemberDAO.java
License:Open Source License
public List<HLocaleMember> findActiveMembers(LocaleId localeId, @Nullable HPerson excludePerson) { StringBuilder sb = new StringBuilder(); sb.append("from HLocaleMember ").append("where id.supportedLanguage.localeId = :localeId "); if (excludePerson != null) { sb.append("and id.person.id <> :excludePerson "); }/*from www. ja va 2s . c o m*/ sb.append("and (isTranslator = true ").append("or isReviewer = true ").append("or isCoordinator = true) ") .append("order by lower(id.person.name)"); Query query = getSession().createQuery(sb.toString()); query.setParameter("localeId", localeId); if (excludePerson != null) { query.setParameter("excludePerson", excludePerson.getId()); } query.setCacheable(true); query.setComment("LocaleMemberDAO.findActiveMembers"); return query.list(); }
From source file:org.zanata.dao.LocaleMemberDAO.java
License:Open Source License
/** * Check if person is a reviewer of any language * * @param personId/* w w w. j a va 2s . c o m*/ * @return */ public List<HLocaleMember> findByPersonWithReviewerRole(Long personId) { Query query = getSession() .createQuery("from HLocaleMember where id.person.id= :personId and isReviewer = :isReviewer"); query.setParameter("personId", personId); query.setParameter("isReviewer", true); query.setComment("LocaleMemberDAO.findByPersonWithReviewerRole"); return query.list(); }
From source file:org.zanata.dao.LocaleMemberDAO.java
License:Open Source License
public boolean isLocaleCoordinator(Long personId, LocaleId localeId) { Query query = getSession() .createQuery("from HLocaleMember as m where m.id.supportedLanguage.localeId = :localeId " + "and m.id.person.id = :personId and m.coordinator = true"); query.setParameter("localeId", localeId).setParameter("personId", personId); query.setComment("LocaleMemberDAO.isLocaleCoordinator"); return query.list().size() > 0; }
From source file:org.zanata.dao.LocaleMemberDAO.java
License:Open Source License
public boolean isLocaleMember(Long personId, LocaleId localeId) { Query query = getSession() .createQuery("from HLocaleMember as m where m.id.supportedLanguage.localeId = :localeId " + "and m.id.person.id = :personId"); query.setParameter("localeId", localeId).setParameter("personId", personId); query.setComment("LocaleMemberDAO.isLocaleMember"); return query.list().size() > 0; }
From source file:org.zanata.dao.LocaleMemberDAO.java
License:Open Source License
public HLocaleMember findByPersonAndLocale(Long personId, LocaleId localeId) { Query query = getSession() .createQuery("from HLocaleMember as m where m.id.supportedLanguage.localeId = :localeId " + "and m.id.person.id = :personId"); query.setParameter("localeId", localeId).setParameter("personId", personId); query.setComment("LocaleMemberDAO.findByPersonAndLocale"); return (HLocaleMember) query.uniqueResult(); }
From source file:org.zanata.dao.PersonDAO.java
License:Open Source License
@SuppressWarnings("unchecked") public List<HLocale> getLanguageMembershipByUsername(String userName) { Query query = getSession().createQuery( "select m.id.supportedLanguage from HLocaleMember as m where m.id.person.account.username = :username"); query.setParameter("username", userName); query.setCacheable(false);/* w ww . ja v a 2s . c om*/ query.setComment("PersonDAO.getLanguageMembershipByUsername"); List<HLocale> re = new ArrayList<HLocale>(); List<HLocale> su = query.list(); for (HLocale lan : su) { if (lan.isActive()) { re.add(lan); } } return re; }
From source file:org.zanata.dao.PersonDAO.java
License:Open Source License
@SuppressWarnings("unchecked") public List<HProject> getMaintainerProjectByUsername(String userName) { Query query = getSession() .createQuery("select p.maintainerProjects from HPerson as p where p.account.username = :username"); query.setParameter("username", userName); query.setCacheable(false);/*from w w w. j a v a2s . co m*/ query.setComment("PersonDAO.getMaintainerProjectByUsername"); return query.list(); }
From source file:org.zanata.dao.PersonDAO.java
License:Open Source License
public HPerson findByUsername(String username) { Query query = getSession().createQuery("from HPerson as p where p.account.username = :username"); query.setParameter("username", username); query.setCacheable(false);/* ww w.j av a2 s.co m*/ query.setComment("PersonDAO.findByUsername"); return (HPerson) query.uniqueResult(); }
From source file:org.zanata.dao.PersonDAO.java
License:Open Source License
public String findEmail(String username) { Query query = getSession() .createQuery("select p.email from HPerson as p where p.account.username = :username"); query.setParameter("username", username); query.setCacheable(false);//www. j ava 2 s . co m query.setComment("PersonDAO.findEmail"); return (String) query.uniqueResult(); }