List of usage examples for javax.persistence TypedQuery setParameter
TypedQuery<X> setParameter(int position, Object value);
From source file:org.openmeetings.app.data.conference.PollManagement.java
public boolean hasPoll(Long room_id) { try {//from w ww.java 2s .c o m log.debug(" :: hasPoll :: " + room_id); TypedQuery<Long> q = em.createQuery( "SELECT COUNT(rp) FROM RoomPoll rp WHERE rp.room.rooms_id = :room_id AND rp.archived = :archived", Long.class); q.setParameter("room_id", room_id); q.setParameter("archived", false); return q.getSingleResult() > 0; } catch (NoResultException nre) { //expected } catch (Exception err) { log.error("[getPoll]", err); } return false; }
From source file:eu.ggnet.dwoss.report.ReportAgentBean.java
@Override public List<ReportLine> find(SearchParameter search, int firstResult, int maxResults) { StringBuilder sb = new StringBuilder("Select l from ReportLine l"); if (!StringUtils.isBlank(search.getRefurbishId())) sb.append(" where l.refurbishId = :refurbishId"); L.debug("Using created SearchQuery:{}", sb); TypedQuery<ReportLine> q = reportEm.createQuery(sb.toString(), ReportLine.class); if (!StringUtils.isBlank(search.getRefurbishId())) q.setParameter("refurbishId", search.getRefurbishId().trim()); q.setFirstResult(firstResult);//from w ww . ja v a 2 s.c o m q.setMaxResults(maxResults); return q.getResultList(); }
From source file:org.openmeetings.app.data.conference.PollManagement.java
public RoomPoll getPoll(Long room_id) { try {/*from w w w . j ava 2s . c o m*/ log.debug(" :: getPoll :: " + room_id); TypedQuery<RoomPoll> q = em.createQuery( "SELECT rp FROM RoomPoll rp WHERE rp.room.rooms_id = :room_id AND rp.archived = :archived", RoomPoll.class); q.setParameter("room_id", room_id); q.setParameter("archived", false); return q.getSingleResult(); } catch (NoResultException nre) { //expected } catch (Exception err) { log.error("[getPoll]", err); } return null; }
From source file:org.openmeetings.app.data.conference.PollManagement.java
public List<RoomPoll> getArchivedPollList(Long room_id) { try {/*w w w . j a v a 2 s . c o m*/ log.debug(" :: getPoll :: " + room_id); TypedQuery<RoomPoll> q = em.createQuery( "SELECT rp FROM RoomPoll rp WHERE rp.room.rooms_id = :room_id AND rp.archived = :archived", RoomPoll.class); q.setParameter("room_id", room_id); q.setParameter("archived", true); return q.getResultList(); } catch (NoResultException nre) { //expected } catch (Exception err) { log.error("[getPoll]", err); } return null; }
From source file:org.openmeetings.app.data.user.dao.UserContactsDaoImpl.java
public UserContacts getUserContactByShareCalendar(Long contactId, Boolean shareCalendar, Long userId) { try {/*w w w. j ava2s .com*/ String hql = "select c from UserContacts c " + "where c.contact.user_id = :userId " + "AND c.owner.user_id = :contactId " + "AND c.shareCalendar = :shareCalendar " + "AND c.contact.deleted <> 'true'"; TypedQuery<UserContacts> query = em.createQuery(hql, UserContacts.class); query.setParameter("contactId", contactId); query.setParameter("userId", userId); query.setParameter("shareCalendar", shareCalendar); List<UserContacts> ll = query.getResultList(); if (ll.size() > 0) { return ll.get(0); } } catch (Exception e) { log.error("[getUserContactByShareCalendar]", e); } return null; }
From source file:org.openmeetings.app.data.user.dao.UsersDaoImpl.java
public Users getUserByName(String login) { try {//from ww w. j av a 2 s .c o m String hql = "SELECT u FROM Users as u " + " where u.login = :login" + " AND u.deleted <> :deleted"; TypedQuery<Users> query = em.createQuery(hql, Users.class); query.setParameter("login", login); query.setParameter("deleted", "true"); Users us = null; try { us = query.getSingleResult(); } catch (NoResultException ex) { } return us; } catch (Exception e) { log.error("[getUserByAdressesId]", e); } return null; }
From source file:org.openmeetings.app.data.user.dao.UsersDaoImpl.java
/** * @param search/*from w w w. j a v a2 s .c o m*/ * @return */ public Long selectMaxFromUsersWithSearch(String search) { try { String hql = "select count(c.user_id) from Users c " + "where c.deleted = 'false' " + "AND (" + "lower(c.login) LIKE :search " + "OR lower(c.firstname) LIKE :search " + "OR lower(c.lastname) LIKE :search " + ")"; // get all users TypedQuery<Long> query = em.createQuery(hql, Long.class); query.setParameter("search", StringUtils.lowerCase(search)); List<Long> ll = query.getResultList(); log.info("selectMaxFromUsers" + ll.get(0)); return ll.get(0); } catch (Exception ex2) { log.error("[selectMaxFromUsers] ", ex2); } return null; }
From source file:org.openmeetings.app.data.user.dao.UsersDaoImpl.java
public Users getUserByEmail(String email) { try {// w w w .j a v a 2 s . c om String hql = "SELECT u FROM Users as u " + " where u.adresses.email = :email" + " AND u.deleted <> :deleted"; TypedQuery<Users> query = em.createQuery(hql, Users.class); query.setParameter("email", email); query.setParameter("deleted", "true"); Users us = null; try { us = query.getSingleResult(); } catch (NoResultException ex) { } return us; } catch (Exception e) { log.error("[getUserByAdressesId]", e); } return null; }
From source file:eu.domibus.ebms3.common.dao.PModeDao.java
protected String findAgreementRef(final AgreementRef agreementRef) throws EbMS3Exception { if (agreementRef == null || agreementRef.getValue() == null || agreementRef.getValue().isEmpty()) { return ""; //AgreementRef is optional }/*from www . java 2 s.c om*/ final String value = agreementRef.getValue(); final String pmode = agreementRef.getPmode(); //FIXME? This value is ignored! final String type = agreementRef.getType(); final TypedQuery<String> query = this.entityManager.createNamedQuery("Agreement.findByValueAndType", String.class); query.setParameter("VALUE", value); query.setParameter("TYPE", (type == null) ? "" : type); try { return query.getSingleResult(); } catch (final NoResultException e) { PModeDao.LOG.info("No matching agreementRef found", e); } throw new EbMS3Exception(EbMS3Exception.EbMS3ErrorCode.EBMS_0001, "No matching agreementRef found", null, null, null);//FIXME: Throw ValueInconsistent if CPA not recognized [5.2.2.7] }
From source file:com.abiquo.server.core.cloud.VirtualMachineDAO.java
public boolean hasVirtualMachineTemplate(final Integer virtualMachineTemplateId) { TypedQuery<Long> query = getEntityManager().createNamedQuery("VIRTUAL_MACHINE.HAS_VMT", Long.class); query.setParameter("virtualMachineTplId", virtualMachineTemplateId); return query.getResultList().get(0) > 0; }