List of usage examples for javax.persistence Query setParameter
Query setParameter(int position, Object value);
From source file:eu.planets_project.tb.impl.persistency.ServiceRecordPersistencyImpl.java
@SuppressWarnings("unchecked") public List<ServiceRecordImpl> getAllServiceRecordsOfType(String type) { Query query = manager.createQuery("from ServiceRecordImpl where serviceType=:type"); query.setParameter("type", type); return (List<ServiceRecordImpl>) query.getResultList(); }
From source file:eu.planets_project.tb.impl.persistency.ServiceRecordPersistencyImpl.java
@SuppressWarnings("unchecked") public List<ServiceRecordImpl> getAllServiceRecordsForEndpoint(String endpoint) { Query query = manager.createQuery("from ServiceRecordImpl where endpoint=:endpoint"); query.setParameter("endpoint", endpoint); return (List<ServiceRecordImpl>) query.getResultList(); }
From source file:DAO.MessagesDAOImpl.java
/** * * @param destinataireId/*from w w w . ja v a 2 s . com*/ * @return */ @Transactional(readOnly = true) @Override public List<MessagesEntity> findByDestinataire(int destinataireId) { Query q = em.createQuery("SELECT m FROM MessagesEntity m where m.destinataire.id <> ?"); q.setParameter(1, destinataireId); return q.getResultList(); }
From source file:org.simbasecurity.core.domain.repository.UserDatabaseRepository.java
@SuppressWarnings("unchecked") @Override/*from ww w. j a va2 s .com*/ public Collection<User> findNotLinked(Role role) { Query query = entityManager.createQuery("SELECT user FROM UserEntity user WHERE :role not in " + "elements(user.roles) order by user.userName"); query.setParameter("role", role); return new ArrayList<User>(query.getResultList()); }
From source file:com.solidmaps.webapp.dao.LicenseEXDAO.java
/** * Consulta a Licensa que est vigente no Periodo informado. * O correto essa consulta retornar apenas um resultado, j que no * possivel ter mais de uma licena na mesma data de Expirao. * //from www .ja v a2 s .c om * @param idCompany * @param referenceDate * @return */ public LicenseEXEntity findByCompanyDateReference(Integer idCompany, Calendar initialReferenceDate, Calendar finalReferenceDate) { StringBuilder sb = new StringBuilder(); sb.append("from LicenseEXEntity e where e.company.idCompany =:idCompany "); sb.append("and e.isActive =:active "); sb.append("and e.dateExpiration >= :initialReferenceDate "); sb.append("and e.dateExpiration <= :finalReferenceDate "); sb.append("order by e.dateExpiration desc "); Query query = super.getEm().createQuery(sb.toString()); query.setParameter("idCompany", idCompany); query.setParameter("active", Boolean.TRUE); query.setParameter("initialReferenceDate", initialReferenceDate); query.setParameter("finalReferenceDate", finalReferenceDate); @SuppressWarnings("unchecked") List<LicenseEXEntity> list = query.getResultList(); if (list != null && !list.isEmpty()) { return list.get(0); } return null; }
From source file:org.kuali.mobility.push.dao.PushDeviceTupleDaoImpl.java
@SuppressWarnings("unchecked") public List<PushDeviceTuple> findTuplesForPush(Push push) { Query query = entityManager.createNamedQuery("PushDeviceTuple.findTuplesForPush"); query.setParameter("pushId", push.getPushId()); return query.getResultList(); }
From source file:com.actionbazaar.email.EmailService.java
/** * Sends out an email/* w w w . ja va 2s.c o m*/ * @param message - message to be sent */ public void onMessage(Message message) { try { EmailRequest emailRequest = (EmailRequest) ((ObjectMessage) message).getObject(); Query query = entityManager.createQuery("select e from Email e where e.action = ?1"); query.setParameter(1, emailRequest.getAction()); List results = query.getResultList(); if (results.size() != 1) { logger.severe("A total of " + results.size() + " email templates were returned for action " + emailRequest.getAction()); return; } System.out.println("--> Sending email."); Email emailInfo = (Email) results.get(0); logger.info("Speaker Directory: " + attachmentDirectory); HtmlEmail email = new HtmlEmail(); email.setMailSession(mailSession); email.setTextMsg("Hello World!"); // email.setSubject(template.getSubject()); email.addTo("rcuprak@mac.com"); email.setFrom("java@ctjava.org"); // email.send(); /* emailTemplate.process(emailRecipient.getReplacementTokens()); for (Map.Entry<String,File> entry : emailTemplate.getCidMappings().entrySet()) { email.embed(entry.getValue(),entry.getKey()); } email.setHtmlMsg(emailTemplate.getPatchedEmail()); */ } catch (Throwable t) { t.printStackTrace(); //context.setRollbackOnly(); } }
From source file:com.vizaco.onlinecontrol.dao.jpa.JpaStudentDaoImpl.java
@Override public Student findById(String id) { Query query = this.em.createQuery( "SELECT DISTINCT student FROM Student student left join fetch student.users WHERE student.studentId =:id"); query.setParameter("id", id); return (Student) query.getSingleResult(); }
From source file:cz.fi.muni.pa036.airticketbooking.dao.impl.BaggageDaoImpl.java
@Override public List<Baggage> getByFlightTicket(Long ticket) { try {//from ww w . j av a2s . c om Query q = em.createQuery("FROM Baggage WHERE flight_ticket_id=:ticket"); q.setParameter("ticket", ticket); List<Baggage> planes = q.getResultList(); return Collections.unmodifiableList(planes); } catch (PersistenceException | IllegalArgumentException ex) { throw new DataAccessException(ex.getMessage(), ex) { }; } }
From source file:de.inetsource.jsfforum.db.ThreadFacade.java
private Post getPost(Thread t, boolean last) { try {//from w w w .j a v a2 s.c o m String sort = "asc"; if (last) { sort = "desc"; } Query q = em.createQuery("SELECT p FROM Post p where p.threadId = :thread order by p.created " + sort, Post.class); q.setParameter("thread", t); q.setMaxResults(1); return (Post) q.getSingleResult(); } catch (NoResultException nre) { return null; } }