List of usage examples for javax.persistence TypedQuery setParameter
TypedQuery<X> setParameter(int position, Object value);
From source file:org.openmeetings.app.data.basic.ErrorManagement.java
public ErrorType getErrorType(Long errortype_id) { try {//from w w w . j a va 2 s . co m String hql = "select c from ErrorType as c " + "WHERE c.deleted <> :deleted AND c.errortype_id = :errortype_id"; TypedQuery<ErrorType> query = em.createQuery(hql, ErrorType.class); query.setParameter("deleted", "true"); query.setParameter("errortype_id", errortype_id); return query.getSingleResult(); } catch (Exception ex2) { log.error("[getErrorType(" + errortype_id + ")]", ex2); } return null; }
From source file:org.openmeetings.app.data.basic.FieldLanguageDaoImpl.java
public FieldLanguage getFieldLanguageById(Long language_id) { try {//w ww . j a va 2 s . c om String hql = "select c from FieldLanguage as c " + "WHERE c.deleted <> :deleted " + "AND c.language_id = :language_id"; TypedQuery<FieldLanguage> query = em.createQuery(hql, FieldLanguage.class); query.setParameter("deleted", "true"); query.setParameter("language_id", language_id); FieldLanguage fl = null; try { fl = query.getSingleResult(); } catch (NoResultException ex) { } return fl; } catch (Exception ex2) { log.error("[getLanguageById]: ", ex2); } return null; }
From source file:org.terasoluna.tourreservation.domain.repository.tourinfo.TourInfoRepositoryImpl.java
protected List<TourInfo> findTourInfo(TourInfoSearchCriteria criteria, Pageable pageable) { String q = buildJpql(criteria.getTourDays(), criteria.getBasePrice()); TypedQuery<TourInfo> query = entityManager.createQuery(q, TourInfo.class); query.setParameter("adultCount", criteria.getAdultCount()); query.setParameter("childCount", criteria.getChildCount()); query.setParameter("depDay", criteria.getDepDate()); query.setParameter("depCode", criteria.getDepCode()); query.setParameter("arrCode", criteria.getArrCode()); if (criteria.getTourDays() != 0) { query.setParameter("tourDays", criteria.getTourDays()); }//from ww w.j a va 2s . c o m if (criteria.getBasePrice() != 0) { query.setParameter("basePrice", criteria.getBasePrice()); } query.setFirstResult(pageable.getOffset()); query.setMaxResults(pageable.getPageSize()); List<TourInfo> tourInfoList = query.getResultList(); return tourInfoList; }
From source file:org.cleverbus.core.common.dao.ExternalCallDaoJpaImpl.java
@Override public List<ExternalCall> findProcessingExternalCalls(int interval) { final Date startProcessLimit = DateUtils.addSeconds(new Date(), -interval); String jSql = "SELECT c " + "FROM " + ExternalCall.class.getName() + " c " + "WHERE c.state = '" + ExternalCallStateEnum.PROCESSING + "'" + " AND c.lastUpdateTimestamp < :time"; TypedQuery<ExternalCall> q = em.createQuery(jSql, ExternalCall.class); q.setParameter("time", new Timestamp(startProcessLimit.getTime())); q.setMaxResults(MAX_MESSAGES_IN_ONE_QUERY); return q.getResultList(); }
From source file:com.deltastar.task7.core.repository.api.impl.PositionRepositoryImpl.java
@Override public Position getPossessedPositionByCustomerIdAndFundId(int customerId, int fundId) { TypedQuery<Position> query = entityManager.createNamedQuery("findPositionByCustomerIdAndFundId", Position.class); query.setParameter("p_customerId", customerId); query.setParameter("p_fundId", fundId); query.setParameter("p_status", CCConstants.POSITION_STATUS_IN_POSSESSION); List<Position> tempResultList = query.getResultList(); return tempResultList != null && tempResultList.size() > 0 ? tempResultList.get(0) : null; }
From source file:com.epam.ipodromproject.repository.jpa.JPABetRepository.java
@Override public long getTotalArchivedBetsMadeByUser(String username) { TypedQuery<Long> query = entityManager.createNamedQuery("Bet.findBetsPagesArchivedByUser", Long.class); query.setParameter("username", username); query.setParameter("betResult", BetResult.NOT_CONSIDERED); long pages = 1; try {/*w w w.j ava2 s. co m*/ pages = query.getSingleResult(); } catch (Exception e) { pages = (long) 1; } return pages; }
From source file:com.siriusit.spezg.multilib.storage.jpa.JpaPersonRepository.java
@Override public List<? extends Person> findPersonsByTitle(String title) { TypedQuery<PersonDomainObject> query = entityManager.createNamedQuery("findPersonsByTitle", PersonDomainObject.class); query.setParameter("title", title); return query.getResultList(); }
From source file:eu.domibus.common.dao.MessagingDao.java
public UserMessage findUserMessageByMessageId(final String messageId) { final TypedQuery<UserMessage> query = this.em.createNamedQuery("Messaging.findUserMessageByMessageId", UserMessage.class); query.setParameter("MESSAGE_ID", messageId); return DataAccessUtils.singleResult(query.getResultList()); }
From source file:com.siriusit.spezg.multilib.storage.jpa.JpaBinaryAttachmentRepository.java
@Override public BinaryAttachment findBinaryAttachmentByUnit(Unit unit) { TypedQuery<BinaryAttachmentDomainObject> query = entityManager .createNamedQuery("findAttachmentByUnitAndType", BinaryAttachmentDomainObject.class); query.setParameter("unit", unit); return query.getSingleResult(); }
From source file:com.siriusit.spezg.multilib.storage.jpa.JpaMessageRepository.java
@Override public List<? extends Message> findMessagesByReceiver(Person receiver) { TypedQuery<MessageDomainObject> query = entityManager.createNamedQuery("findMessageByReceiver", MessageDomainObject.class); query.setParameter("receiver", receiver); return query.getResultList(); }