List of usage examples for javax.persistence TypedQuery getSingleResult
X getSingleResult();
From source file:org.apache.openmeetings.db.dao.user.AbstractUserDao.java
private User get(long user_id, boolean force) { if (user_id > 0) { TypedQuery<User> query = em.createNamedQuery("getUserById", User.class); query.setParameter("user_id", user_id); User users = null;//from w w w. j av a2s .c o m try { if (force) { @SuppressWarnings("unchecked") OpenJPAQuery<User> kq = OpenJPAPersistence.cast(query); kq.getFetchPlan().addFetchGroup("backupexport"); users = kq.getSingleResult(); } else { users = query.getSingleResult(); } } catch (NoResultException ex) { } return users; } else { log.info("[getUser] " + "Info: No USER_ID given"); } return null; }
From source file:org.apache.openmeetings.db.dao.user.AbstractUserDao.java
/** * @param hash/*ww w . j a va2 s .com*/ * @return */ public User getUserByActivationHash(String hash) { TypedQuery<User> query = em.createQuery( "SELECT u FROM User as u WHERE u.activatehash = :activatehash" + " AND u.deleted = false", User.class); query.setParameter("activatehash", hash); User u = null; try { u = query.getSingleResult(); } catch (NoResultException e) { // u=null} } return u; }
From source file:org.apache.openmeetings.db.dao.user.AbstractUserDao.java
public Long searchCountUserProfile(long userId, String text, String offers, String search) { StringBuilder sb = getUserProfileQuery(true, text, offers, search); log.debug("hql :: " + sb.toString()); TypedQuery<Long> query = em.createQuery(sb.toString(), Long.class); setAdditionalParams(query, false, userId); if (text != null && text.length() != 0) { query.setParameter("search", StringUtils.lowerCase("%" + text + "%")); }/*w w w. jav a 2s. co m*/ if (offers != null && offers.length() != 0) { query.setParameter("userOffers", StringUtils.lowerCase("%" + offers + "%")); } if (search != null && search.length() != 0) { query.setParameter("userSearchs", StringUtils.lowerCase("%" + search + "%")); } return query.getSingleResult(); }
From source file:org.apache.openmeetings.db.dao.user.PrivateMessageDao.java
@Override public PrivateMessage get(Long id) { TypedQuery<PrivateMessage> query = em.createNamedQuery("getPrivateMessageById", PrivateMessage.class); query.setParameter("id", id); PrivateMessage privateMessage = null; try {//from w w w . j a v a 2 s . c o m privateMessage = query.getSingleResult(); } catch (NoResultException ex) { } return privateMessage; }
From source file:org.apache.openmeetings.db.dao.user.PrivateMessageDao.java
public Long count(Long ownerId, Long folderId, String search) { TypedQuery<Long> query = em.createQuery(getQuery(true, search, null, true), Long.class); query.setParameter("ownerId", ownerId); if (!StringUtils.isEmpty(search)) { query.setParameter("search", StringUtils.lowerCase("%" + search + "%")); }/*from w w w . j av a 2 s .c o m*/ query.setParameter("folderId", folderId); return query.getSingleResult(); }
From source file:org.apache.openmeetings.db.dao.user.PrivateMessagesDao.java
public PrivateMessage get(long id) { TypedQuery<PrivateMessage> query = em.createNamedQuery("getPrivateMessageById", PrivateMessage.class); query.setParameter("id", id); PrivateMessage privateMessage = null; try {/*from w ww .j av a 2s .com*/ privateMessage = query.getSingleResult(); } catch (NoResultException ex) { } return privateMessage; }
From source file:org.apache.openmeetings.db.dao.user.UserDao.java
@Override public long count() { // get all users TypedQuery<Long> q = em.createNamedQuery("countNondeletedUsers", Long.class); return q.getSingleResult(); }
From source file:org.apache.openmeetings.db.dao.user.UserDao.java
public long count(String search, boolean filterContacts, Long currentUserId) { Map<String, Object> params = new HashMap<String, Object>(); TypedQuery<Long> q = em.createQuery( DaoHelper.getSearchQuery("User", "u", getAdditionalJoin(filterContacts), search, true, true, true, getAdditionalWhere(filterContacts, currentUserId, params), null, searchFields), Long.class); setAdditionalParams(q, params);//from w w w . j ava 2s . co m return q.getSingleResult(); }
From source file:org.apache.rave.portal.repository.impl.JpaPageRepository.java
@Override public boolean hasPersonPage(String userId) { TypedQuery<Long> query = manager.createNamedQuery(JpaPage.USER_HAS_PERSON_PAGE, Long.class); query.setParameter("userId", userId); query.setParameter("pageType", PageType.PERSON_PROFILE.toString().toUpperCase()); return query.getSingleResult() > 0; }
From source file:org.apache.rave.portal.repository.impl.JpaPageRepository.java
@Override public boolean hasPage(String contextId, String pageType) { TypedQuery<Long> query = manager.createNamedQuery(JpaPage.HAS_CONTEXT_PAGE, Long.class); query.setParameter("contextId", contextId); query.setParameter("pageType", pageType); return query.getSingleResult() > 0; }