List of usage examples for javax.persistence TypedQuery setParameter
TypedQuery<X> setParameter(int position, Object value);
From source file:hr.diskobolos.persistence.impl.EvaluationAnswerPersistenceImpl.java
@Override public Long fetchNumberOfMemberRegistersWithoutTerms() { CriteriaBuilder cb = entityManager.getCriteriaBuilder(); CriteriaQuery<Long> cq = cb.createQuery(Long.class); Root<MemberRegister> memberRegister = cq.from(MemberRegister.class); Subquery<Long> sq = cq.subquery(Long.class); Root<EvaluationAnswer> evaluationAnswer = sq.from(EvaluationAnswer.class); Join<EvaluationAnswer, QuestionChoicesDef> choiceDef = evaluationAnswer.join(EvaluationAnswer_.answer); Join<QuestionChoicesDef, EvaluationQuestionDef> questionDef = choiceDef .join(QuestionChoicesDef_.evaluationQuestionDef); ParameterExpression<QuestionnaireType> questionnaireType = cb.parameter(QuestionnaireType.class, "questionnaireType"); sq.select(evaluationAnswer.get("memberRegister").get("id")) .where(cb.equal(questionDef.get(EvaluationQuestionDef_.questionnaireType), questionnaireType)); cq.select(cb.count(memberRegister.get("id"))).where(cb.not(cb.in(memberRegister.get("id")).value(sq))); TypedQuery<Long> query = entityManager.createQuery(cq); query.setParameter("questionnaireType", QuestionnaireType.TERMS_OF_CONDITION); return query.getSingleResult(); }
From source file:com.expressui.core.dao.security.query.UserQuery.java
@Override public void setParameters(TypedQuery<Serializable> typedQuery) { if (hasValue(loginName)) { typedQuery.setParameter("loginName", "%" + loginName.toUpperCase() + "%"); }//from ww w . ja v a 2s .c o m if (hasValue(doesNotBelongToRole)) { typedQuery.setParameter("doesNotBelongToRole", doesNotBelongToRole); } }
From source file:com.siriusit.spezg.multilib.storage.jpa.JpaPersonRepository.java
@Override public Person findPersonByUsername(String username) { TypedQuery<PersonDomainObject> query = entityManager.createNamedQuery("findPersonByUsername", PersonDomainObject.class); query.setParameter("username", username); return query.getSingleResult(); }
From source file:com.beto.test.securityinterceptor.security.UserPageRoleServiceImpl.java
@Override public List<SecPageRoleDef> findUrlByUrl(String url) throws Exception { List<SecPageRoleDef> pageRoles = null; try {/* w w w . j a va 2 s. com*/ url = StringUtils.substringBefore(url, "?"); logger.debug("findUrlByUrl method is called..." + url); TypedQuery<SecPageDef> createQuery = em.createNamedQuery("SecPageDef.findByViewId", SecPageDef.class); createQuery.setParameter("viewId", url); pageRoles = createQuery.getSingleResult().getSecPageRoleDefList(); for (SecPageRoleDef pageRole : pageRoles) { logger.debug(pageRole.toString()); } } catch (NoResultException e) { // TODO: handle exception } return pageRoles; }
From source file:com.simplecrud.dao.LogInDao.java
public Object getUserId(String username, String password) { TypedQuery<NewMember> q = em.createQuery( "SELECT n.id FROM NewMember n WHERE n.username = :username AND n.password = :password", NewMember.class); q.setParameter("username", username); q.setParameter("password", password); return q.getSingleResult(); }
From source file:org.mitre.openid.connect.repository.impl.JpaApprovedSiteRepository.java
@Override @Transactional(value = "defaultTransactionManager") public Collection<ApprovedSite> getByUserId(String userId) { TypedQuery<ApprovedSite> query = manager.createNamedQuery(ApprovedSite.QUERY_BY_USER_ID, ApprovedSite.class); query.setParameter(ApprovedSite.PARAM_USER_ID, userId); return query.getResultList(); }
From source file:com.epam.ipodromproject.repository.jpa.JPABetRepository.java
@Override public long getTotalActiveBetsMadeByUser(String username) { TypedQuery<Long> query = entityManager.createNamedQuery("Bet.findNumberOfActiveBetsByUsername", Long.class); query.setParameter("betResult", BetResult.NOT_CONSIDERED); query.setParameter("username", username); long pages;/*from w w w. ja va 2 s .c om*/ try { pages = query.getSingleResult(); } catch (Exception e) { pages = (long) 1; } return pages; }
From source file:org.mitre.openid.connect.repository.impl.JpaApprovedSiteRepository.java
@Override @Transactional(value = "defaultTransactionManager") public Collection<ApprovedSite> getByClientId(String clientId) { TypedQuery<ApprovedSite> query = manager.createNamedQuery(ApprovedSite.QUERY_BY_CLIENT_ID, ApprovedSite.class); query.setParameter(ApprovedSite.PARAM_CLIENT_ID, clientId); return query.getResultList(); }
From source file:csns.model.academics.dao.jpa.CourseDaoImpl.java
@Override public List<Course> searchCourses(String term, int maxResults) { TypedQuery<Course> query = entityManager.createNamedQuery("course.search", Course.class); if (maxResults > 0) query.setMaxResults(maxResults); return query.setParameter("term", term).getResultList(); }
From source file:eu.domibus.common.dao.MessagingDao.java
public SignalMessage findSignalMessageByMessageId(final String messageId) { final TypedQuery<SignalMessage> query = this.em.createNamedQuery("Messaging.findSignalMessageByMessageId", SignalMessage.class); query.setParameter("MESSAGE_ID", messageId); return DataAccessUtils.singleResult(query.getResultList()); }