List of usage examples for javax.persistence TypedQuery setParameter
TypedQuery<X> setParameter(int position, Object value);
From source file:org.jasig.portlet.notice.service.jpa.JpaNotificationDao.java
@Override @Transactional(readOnly = true)/*from w w w . j av a 2 s . co m*/ public Set<JpaEntry> getEntriesByRecipient(String username) { Validate.notEmpty(username, "Argument 'username' cannot be empty"); final String jpql = "SELECT DISTINCT v.entry FROM JpaEvent v " + "WHERE v.username = :username"; TypedQuery<JpaEntry> query = entityManager.createQuery(jpql, JpaEntry.class); log.debug("Query getEntriesByRecipient={}", query.toString()); query.setParameter("username", username); List<JpaEntry> rslt = query.getResultList(); return new HashSet<JpaEntry>(rslt); }
From source file:org.openmeetings.app.data.calendar.daos.MeetingMemberDaoImpl.java
public MeetingMember getMeetingMemberById(Long meetingMemberId) { try {/*from w w w . j a va 2s .c o m*/ log.debug("getMeetingMemberById: " + meetingMemberId); String hql = "select app from MeetingMember app " + "WHERE app.deleted <> :deleted " + "AND app.meetingMemberId = :meetingMemberId"; TypedQuery<MeetingMember> query = em.createQuery(hql, MeetingMember.class); query.setParameter("deleted", true); query.setParameter("meetingMemberId", meetingMemberId); MeetingMember meetingMember = null; try { meetingMember = query.getSingleResult(); } catch (NoResultException ex) { } return meetingMember; } catch (Exception ex2) { log.error("[getMeetingMemberById]: ", ex2); } return null; }
From source file:eu.domibus.ebms3.common.dao.PModeDao.java
@Override public Action getAction(final String pModeKey) { final TypedQuery<Action> query = this.entityManager.createNamedQuery("Action.findByName", Action.class); query.setParameter("NAME", this.getActionNameFromPModeKey(pModeKey)); return query.getSingleResult(); }
From source file:com.music.dao.PieceDao.java
public List<Piece> getPiecesInRange(DateTime start, DateTime end) { TypedQuery<Piece> query = getEntityManager().createQuery( "SELECT p FROM Piece p WHERE p.generationTime > :start AND p.generationTime < :end", Piece.class); query.setParameter("start", start); query.setParameter("end", end); return query.getResultList(); }
From source file:com.epam.training.taranovski.web.project.repository.implementation.VacancyRepositoryImplementation.java
@Override public List<Employee> getAppropriateAvailableEmployees(Vacancy vacancy) { EntityManager em = entityManagerFactory.createEntityManager(); List<Integer> list = null; List<Employee> list1 = new LinkedList<>(); try {/*from w ww .j a va 2s .c om*/ em.getTransaction().begin(); Query query = em.createNativeQuery( "select \"employeeId\" from (select \"employeeId\", \"vacancyId\" as \"ide\", count(*) as cou from (select \"UserSkill\".\"employeeId\", \"VacancySkill\".\"vacancyId\", \"UserSkill\".\"experience\", \"VacancySkill\".\"experience\" from \"UserSkill\" join \"VacancySkill\" on \"UserSkill\".\"allSkillsId\" = \"VacancySkill\".\"allSkillsId\" where \"UserSkill\".\"experience\" >= \"VacancySkill\".\"experience\" and \"VacancySkill\".\"vacancyId\" = ?) group by \"employeeId\", \"vacancyId\") where cou = (select count(*) from \"VacancySkill\" where \"VacancySkill\".\"vacancyId\" = \"ide\")"); query.setParameter(1, vacancy.getVacancyId()); list = query.getResultList(); if (list.isEmpty()) { list.add(0); } TypedQuery<Employee> query1 = em.createNamedQuery("Employee.findAmongIdsFreeEmployees", Employee.class); query1.setParameter("employeeIdList", list); list1 = query1.getResultList(); em.getTransaction().commit(); } catch (RuntimeException e) { Logger.getLogger(VacancyRepositoryImplementation.class.getName()).info(e); } finally { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } em.close(); } return list1; }
From source file:eu.domibus.ebms3.common.dao.PModeDao.java
@Override public Service getService(final String pModeKey) { final TypedQuery<Service> query = this.entityManager.createNamedQuery("Service.findByName", Service.class); query.setParameter("NAME", this.getServiceNameFromPModeKey(pModeKey)); //FIXME enable multiple ServiceTypes with the same name return query.getSingleResult(); }
From source file:eu.domibus.ebms3.common.dao.PModeDao.java
@Override public int getRetentionDownloadedByMpcName(final String mpcName) { final TypedQuery<Mpc> query = entityManager.createNamedQuery("Mpc.findByQualifiedName", Mpc.class); query.setParameter("QUALIFIED_NAME", mpcName); final Mpc result = query.getSingleResult(); if (result == null) { PModeDao.LOG.error("No mpc with name: " + mpcName + " found. Assuming message retention of 0 for downloaded messages."); return 0; }//w w w . ja v a 2s.c o m return result.getRetentionDownloaded(); }
From source file:com.ilkgunel.hastaneotomasyonu.service.AvailableAppointmentsService.java
public Boolean[] changeRenderingStates(SaveAppointments saveAppointments) { int doctorid = 0; int uygunrandevuid = 0; if (saveAppointments != null) { doctorid = saveAppointments.getSelectedAppointment().getDoktorid(); uygunrandevuid = saveAppointments.getSelectedAppointment().getUygunrandevuid(); }//from ww w. j a v a2 s . c om TypedQuery<Object[]> doctorAndTimeQuery = em.createQuery( "SELECT u.doktoradi,FUNCTION('DATE',u.tarih),u.uygunrandevuid FROM Uygunrandevular AS u WHERE u.doktorid=:doctorid ORDER BY u.tarih ASC", Object[].class); doctorAndTimeQuery.setParameter("doctorid", doctorid); doctorAndTimeList = new ArrayList<>(); doctorAndTimeList = doctorAndTimeQuery.getResultList(); TypedQuery<Randevusaatleri> query = em .createQuery("SELECT c FROM Randevusaatleri c WHERE c.doktorid=:doctorid", Randevusaatleri.class); System.out.println("Seilen Randevunun ID'si" + uygunrandevuid); query.setParameter("doctorid", uygunrandevuid); appointmentClockResults = new ArrayList<>(); appointmentClockResults = query.getResultList(); Boolean[] array = new Boolean[2]; array[0] = false; array[1] = true; return array; }
From source file:eu.domibus.ebms3.common.dao.PModeDao.java
@Override public int getRetentionUndownloadedByMpcName(final String mpcName) { final TypedQuery<Mpc> query = this.entityManager.createNamedQuery("Mpc.findByQualifiedName", Mpc.class); query.setParameter("QUALIFIED_NAME", mpcName); final Mpc result = query.getSingleResult(); if (result == null) { PModeDao.LOG.error("No mpc with name: " + mpcName + " found. Assuming message retention of -1 for undownloaded messages."); return 0; }//from ww w . j a v a 2 s.c o m return result.getRetentionUndownloaded(); }
From source file:eu.domibus.ebms3.common.dao.PModeDao.java
protected String findActionName(final String action) throws EbMS3Exception { if (action == null || action.isEmpty()) { throw new EbMS3Exception(EbMS3Exception.EbMS3ErrorCode.EBMS_0004, "Action parameter must not be null or empty", null, null, null); }/*from ww w .j av a 2 s. co m*/ final TypedQuery<String> query = this.entityManager.createNamedQuery("Action.findByAction", String.class); query.setParameter("ACTION", action); try { final String actionName = query.getSingleResult(); return actionName; } catch (final NoResultException e) { PModeDao.LOG.info("No matching action found", e); throw new EbMS3Exception(EbMS3Exception.EbMS3ErrorCode.EBMS_0001, "No matching action found", null, null, null); } }