List of usage examples for org.hibernate Query setComment
Query<R> setComment(String comment);
From source file:org.zanata.dao.AccountDAO.java
License:Open Source License
@SuppressWarnings("unchecked") // TODO: use hibernate search public List<HAccount> searchQuery(String searchQuery, int maxResults, int firstResult) { String userName = "%" + searchQuery + "%"; Query query = getSession().createQuery("from HAccount as a where lower(a.username) like lower(:username)"); query.setParameter("username", userName); query.setMaxResults(maxResults);//from ww w . j a va2s.co m query.setFirstResult(firstResult); query.setComment("AccountDAO.searchQuery/username"); return query.list(); }
From source file:org.zanata.dao.AccountDAO.java
License:Open Source License
public List<String> getUserNames(String filter, int offset, int maxResults) { StringBuilder queryBuilder = new StringBuilder("select username from HAccount "); if (!StringUtils.isEmpty(filter)) { queryBuilder.append("where lower(username) like :filter"); }/*from ww w . ja v a 2 s .co m*/ Query query = getSession().createQuery(queryBuilder.toString()); if (!StringUtils.isEmpty(filter)) { query.setParameter("filter", "%" + filter + "%"); } query.setMaxResults(maxResults); query.setFirstResult(offset); query.setCacheable(true); query.setComment("accountDAO.getUserNames"); return (List<String>) query.list(); }
From source file:org.zanata.dao.AccountDAO.java
License:Open Source License
public int getUserCount(String filter) { StringBuilder queryBuilder = new StringBuilder("select count(*) from HAccount "); if (!StringUtils.isEmpty(filter)) { queryBuilder.append("where lower(username) like :filter"); }/*from w w w.j a va 2s.c om*/ Query query = getSession().createQuery(queryBuilder.toString()); if (!StringUtils.isEmpty(filter)) { query.setParameter("filter", "%" + filter + "%"); } query.setCacheable(true); query.setComment("accountDAO.getUserCount"); Long totalCount = (Long) query.uniqueResult(); if (totalCount == null) { return 0; } return totalCount.intValue(); }
From source file:org.zanata.dao.AccountDAO.java
License:Open Source License
public HAccount getByCredentialsId(String credentialsId) { Query query = getSession().createQuery("select c.account from HCredentials c where c.user = :id"); query.setParameter("id", credentialsId); query.setComment("AccountDAO.getByCredentialsId"); return (HAccount) query.uniqueResult(); }
From source file:org.zanata.dao.AccountDAO.java
License:Open Source License
/** * Returns all accounts merged into the another one. * * @param mergedInto/* w ww . ja v a2s . c o m*/ * The account into which all returned accounts were merged. * @return A list of accounts that in the past were merged into the given * account. */ public List<HAccount> getAllMergedAccounts(HAccount mergedInto) { Query query = getSession().createQuery("from HAccount as a where a.mergedInto = :mergedInto"); query.setParameter("mergedInto", mergedInto); query.setComment("AccountDAO.getAllMergedAccounts"); return (List<HAccount>) query.list(); }
From source file:org.zanata.dao.ActivityDAO.java
License:Open Source License
@SuppressWarnings("unchecked") public Activity findActivity(long personId, EntityType contextType, long contextId, ActivityType activityType, Date approxTime) {/*from w w w .ja v a 2 s.c om*/ Query query = getSession().createQuery("FROM Activity a WHERE a.actor.id = :personId " + "AND a.contextId = :contextId " + "AND a.activityType = :activityType " + "AND a.contextType = :contextType " + "AND :approxTime = a.approxTime"); query.setParameter("personId", personId); query.setParameter("contextId", contextId); query.setParameter("activityType", activityType); query.setParameter("contextType", contextType); query.setTimestamp("approxTime", approxTime); query.setCacheable(true); query.setComment("activityDAO.findActivity"); return (Activity) query.uniqueResult(); }
From source file:org.zanata.dao.ActivityDAO.java
License:Open Source License
@SuppressWarnings("unchecked") public List<Activity> findLatestVersionActivitiesByUser(long personId, List<Long> versionIds, int offset, int maxResults) { StringBuilder queryBuilder = new StringBuilder(); queryBuilder.append("FROM Activity a WHERE a.actor.id = :personId "); queryBuilder.append("AND a.contextType = 'HProjectIteration' "); queryBuilder.append("AND a.contextId in (:versionIds) "); queryBuilder.append("order by a.lastChanged DESC"); Query query = getSession().createQuery(queryBuilder.toString()); query.setParameter("personId", personId); query.setParameterList("versionIds", versionIds); query.setMaxResults(maxResults);/*from w ww .ja v a 2s . co m*/ query.setFirstResult(offset); query.setCacheable(true); query.setComment("activityDAO.findLatestVersionActivitiesByUser"); return query.list(); }
From source file:org.zanata.dao.ActivityDAO.java
License:Open Source License
@SuppressWarnings("unchecked") public List<Activity> findLatestVersionActivities(Long versionId, int offset, int maxResults) { StringBuilder queryBuilder = new StringBuilder(); queryBuilder.append("FROM Activity a WHERE a.contextType = 'HProjectIteration' "); queryBuilder.append("AND a.contextId = :versionId "); queryBuilder.append("order by a.lastChanged DESC"); Query query = getSession().createQuery(queryBuilder.toString()); query.setParameter("versionId", versionId); query.setMaxResults(maxResults);/*from ww w . j a v a 2s.c om*/ query.setFirstResult(offset); query.setCacheable(true); query.setComment("activityDAO.findLatestVersionActivities"); return query.list(); }
From source file:org.zanata.dao.ActivityDAO.java
License:Open Source License
@SuppressWarnings("unchecked") public List<Activity> findLatestActivitiesForContext(long personId, long contextId, int offset, int maxResults) { Query query = getSession().createQuery("FROM Activity a WHERE a.actor.id = :personId " + "AND a.contextId = :contextId " + "order by a.lastChanged DESC"); query.setParameter("personId", personId); query.setParameter("contextId", contextId); query.setMaxResults(maxResults);//from www .j a v a 2s. com query.setFirstResult(offset); query.setCacheable(true); query.setComment("activityDAO.findActivities"); return query.list(); }
From source file:org.zanata.dao.ActivityDAO.java
License:Open Source License
public List<Activity> findLatestActivities(long personId, int offset, int maxResults) { Query query = getSession() .createQuery("FROM Activity a WHERE a.actor.id = :personId " + "order by a.lastChanged DESC"); query.setParameter("personId", personId); query.setMaxResults(maxResults);// w ww .jav a 2 s . c o m query.setFirstResult(offset); query.setCacheable(true); query.setComment("activityDAO.findLatestActivities"); return (List<Activity>) query.list(); }