List of usage examples for javax.persistence TypedQuery getSingleResult
X getSingleResult();
From source file:org.apache.falcon.jdbc.MonitoringJdbcStateStore.java
public FeedSLAAlertBean getFeedAlertInstance(String feedName, String clusterName, Date nominalTime) { EntityManager entityManager = getEntityManager(); beginTransaction(entityManager);/*from w w w.j av a 2s. co m*/ TypedQuery<FeedSLAAlertBean> q = entityManager .createNamedQuery(PersistenceConstants.GET_FEED_ALERT_INSTANCE, FeedSLAAlertBean.class); q.setParameter("feedName", feedName); q.setParameter("clusterName", clusterName); q.setParameter("nominalTime", nominalTime); try { return q.getSingleResult(); } finally { commitAndCloseTransaction(entityManager); } }
From source file:org.apache.openmeetings.data.user.dao.PrivateMessagesDao.java
public PrivateMessage getPrivateMessagesById(Long privateMessageId) { try {/*w w w . ja v a 2 s .c o m*/ TypedQuery<PrivateMessage> query = em.createNamedQuery("getPrivateMessagesById", PrivateMessage.class); query.setParameter("privateMessageId", privateMessageId); PrivateMessage privateMessage = null; try { privateMessage = query.getSingleResult(); } catch (NoResultException ex) { } return privateMessage; } catch (Exception e) { log.error("[countPrivateMessagesByUser]", e); } return null; }
From source file:org.apache.openmeetings.data.user.dao.PrivateMessagesDao.java
public Long getNumberMessages(Long toUserId, Long privateMessageFolderId, boolean isRead) { try {/*from w w w. j a v a2s .co m*/ TypedQuery<Long> query = em.createNamedQuery("getNumberMessages", Long.class); query.setParameter("toUserId", toUserId); query.setParameter("isTrash", false); query.setParameter("isRead", false); query.setParameter("privateMessageFolderId", privateMessageFolderId); return query.getSingleResult(); } catch (Exception e) { log.error("[getNumberMessages]", e); } return null; }
From source file:org.apache.openmeetings.data.user.dao.PrivateMessagesDao.java
public int updatePrivateMessagesToTrash(List<Long> privateMessageIds, Boolean isTrash, Long privateMessageFolderId) { try {//from w w w . j a v a 2 s . com Query query = em.createNamedQuery("updatePrivateMessagesToTrash"); query.setParameter("isTrash", isTrash); query.setParameter("privateMessageFolderId", privateMessageFolderId); query.setParameter("privateMessageIds", privateMessageIds); int updatedEntities = query.executeUpdate(); //Refresh the Entities in the Cache as Hibernate will not do it! //FIXME weird code for (Long privateMessageId : privateMessageIds) { TypedQuery<PrivateMessage> querySel = em.createNamedQuery("getPrivateMessagesById", PrivateMessage.class); querySel.setParameter("privateMessageId", privateMessageId); try { querySel.getSingleResult(); } catch (NoResultException ex) { } } return updatedEntities; } catch (Exception e) { log.error("[updatePrivateMessagesToTrash]", e); } return -1; }
From source file:org.apache.openmeetings.data.user.dao.PrivateMessagesDao.java
public int updatePrivateMessagesReadStatus(List<Long> privateMessageIds, Boolean isRead) { try {/*from ww w . java2 s .com*/ Query query = em.createNamedQuery("updatePrivateMessagesReadStatus"); query.setParameter("isRead", isRead); query.setParameter("privateMessageIds", privateMessageIds); int updatedEntities = query.executeUpdate(); //Refresh the Entities in the Cache as Hibernate will not do it! //FIXME weird code for (Long privateMessageId : privateMessageIds) { TypedQuery<PrivateMessage> querySel = em.createNamedQuery("getPrivateMessagesById", PrivateMessage.class); querySel.setParameter("privateMessageId", privateMessageId); try { querySel.getSingleResult(); } catch (NoResultException ex) { } } return updatedEntities; } catch (Exception e) { log.error("[updatePrivateMessagesReadStatus]", e); } return -1; }
From source file:org.apache.openmeetings.data.user.dao.PrivateMessagesDao.java
public Integer moveMailsToFolder(List<Long> privateMessageIds, Long privateMessageFolderId) { try {//from w w w. j a v a 2 s . co m Query query = em.createNamedQuery("moveMailsToFolder"); query.setParameter("privateMessageFolderId", privateMessageFolderId); query.setParameter("privateMessageIds", privateMessageIds); int updatedEntities = query.executeUpdate(); //Refresh the Entities in the Cache as Hibernate will not do it! //FIXME weird code for (Long privateMessageId : privateMessageIds) { TypedQuery<PrivateMessage> querySel = em.createNamedQuery("getPrivateMessagesById", PrivateMessage.class); querySel.setParameter("privateMessageId", privateMessageId); try { querySel.getSingleResult(); } catch (NoResultException ex) { } } return updatedEntities; } catch (Exception e) { log.error("[updatePrivateMessagesReadStatus]", e); } return -1; }
From source file:org.apache.openmeetings.data.user.dao.UsersDao.java
public long count() { // get all users TypedQuery<Long> q = em.createNamedQuery("countNondeletedUsers", Long.class); return q.getSingleResult(); }
From source file:org.apache.openmeetings.data.user.dao.UsersDao.java
public long count(String search) { TypedQuery<Long> q = em.createQuery( DaoHelper.getSearchQuery("User", "u", search, true, true, null, searchFields), Long.class); return q.getSingleResult(); }
From source file:org.apache.openmeetings.data.user.dao.UsersDao.java
public User get(long user_id) { if (user_id > 0) { try {// w w w . j a v a 2 s . c o m TypedQuery<User> query = em.createNamedQuery("getUserById", User.class); query.setParameter("user_id", user_id); User users = null; try { users = query.getSingleResult(); } catch (NoResultException ex) { } return users; } catch (Exception ex2) { log.error("getUser", ex2); } } else { log.info("[getUser] " + "Info: No USER_ID given"); } return null; }
From source file:org.apache.openmeetings.data.user.dao.UsersDao.java
public User getUserByName(String login) { try {//from w w w.j a v a 2s.c om TypedQuery<User> query = em.createNamedQuery("getUserByName", User.class); query.setParameter("login", login); query.setParameter("deleted", true); User us = null; try { us = query.getSingleResult(); } catch (NoResultException ex) { } return us; } catch (Exception e) { log.error("[getUserByAdressesId]", e); } return null; }