List of usage examples for javax.persistence Query setParameter
Query setParameter(int position, Object value);
From source file:cz.fi.muni.pa036.airticketbooking.dao.impl.SeatReservationDaoImpl.java
@Override public List<SeatReservation> getBySeat(Long seat) { try {/* ww w. j av a 2 s . c om*/ Query q = em.createQuery("FROM SeatReservation WHERE seat_id=:seat"); q.setParameter("seat", seat); List<SeatReservation> planes = q.getResultList(); return Collections.unmodifiableList(planes); } catch (PersistenceException | IllegalArgumentException ex) { throw new DataAccessException(ex.getMessage(), ex) { }; } }
From source file:org.apache.cxf.fediz.service.idp.service.jpa.EntitlementDAOJPAImpl.java
@Override public void updateEntitlement(String name, Entitlement entitlement) { Query query = null; query = em.createQuery("select e from Entitlement e where e.name=:name"); query.setParameter("name", name); //@SuppressWarnings("rawtypes") EntitlementEntity entitlementEntity = (EntitlementEntity) query.getSingleResult(); domain2entity(entitlement, entitlementEntity); LOG.debug("Entitlement '{}' added", entitlement.getName()); em.persist(entitlementEntity);/*from ww w . j av a2 s. c o m*/ }
From source file:com.telefonica.euro_iaas.paasmanager.dao.impl.SubNetworkDaoJpaImpl.java
private SubNetwork findByNetworkName(String name, String vdc, String region) throws EntityNotFoundException { Query query = getEntityManager().createQuery( "select p from SubNetwork p where p.name = :name and p.vdc = :vdc and p.region = :region"); query.setParameter("name", name); query.setParameter("vdc", vdc); query.setParameter("region", region); SubNetwork subNetwork = null;/* w w w. ja va 2 s . c om*/ try { subNetwork = (SubNetwork) query.getSingleResult(); } catch (NoResultException e) { String message = " No subNetwork found in the database with id: " + name + " vdc " + vdc + " region " + region + " Exception: " + e.getMessage(); throw new EntityNotFoundException(SubNetwork.class, "name", name); } return subNetwork; }
From source file:be.fedict.eid.applet.beta.SessionContextManagerBean.java
private SessionContextEntity getSessionContextEntity(String httpSessionId) { Query query = this.entityManager .createQuery("FROM SessionContextEntity AS sc WHERE sc.httpSessionId = :httpSessionId"); query.setParameter("httpSessionId", httpSessionId); SessionContextEntity sessionContextEntity = (SessionContextEntity) query.getSingleResult(); return sessionContextEntity; }
From source file:de.berlios.jhelpdesk.dao.jpa.TicketDAOJpa.java
public List<Ticket> getTicketsByStatus(final TicketStatus ticketStatus, final int howMuch) throws DAOException { try {/*from w ww. j av a2 s .c om*/ return this.jpaTemplate.executeFind(new JpaCallback() { public Object doInJpa(EntityManager em) throws PersistenceException { Query query = em.createNamedQuery("Ticket.byStatusOrderByCreateDateDESC"); query.setParameter(1, ticketStatus.toInt()); query.setMaxResults(howMuch); return query.getResultList(); } }); } catch (DataAccessException dae) { throw new DAOException(dae); } }
From source file:gov.nih.nci.integration.dao.DefaultServiceInvocationMessageDao.java
/** * getAllByReferenceMessageId/*from w w w . j av a2s .c o m*/ * * @param refMsgId - messageId * @return Map */ @SuppressWarnings("unchecked") public Map<StrategyIdentifier, ServiceInvocationMessage> getAllByReferenceMessageId(Long refMsgId) { final Query msgsQuery = this.getEm().createQuery("from " + getDomainClass().getSimpleName() + " svcInvMsg where svcInvMsg.referenceMessageId = :referenceMessageId "); msgsQuery.setParameter("referenceMessageId", refMsgId); final List<ServiceInvocationMessage> msgs = msgsQuery.getResultList(); final ConcurrentHashMap<StrategyIdentifier, ServiceInvocationMessage> map = new ConcurrentHashMap<StrategyIdentifier, ServiceInvocationMessage>(); for (ServiceInvocationMessage serviceInvocationMessage : msgs) { map.put(serviceInvocationMessage.getStrategyIdentifier(), serviceInvocationMessage); } return map; }
From source file:org.apache.cxf.fediz.service.idp.service.jpa.ClaimDAOJPAImpl.java
@Override public void deleteClaim(String claimType) { Query query = null; query = em.createQuery("select c from Claim c where c.claimType=:claimtype"); query.setParameter("claimtype", claimType); //@SuppressWarnings("rawtypes") Object claimObj = query.getSingleResult(); em.remove(claimObj);//ww w . j a v a2 s .c o m LOG.debug("Claim '{}' deleted", claimType); }
From source file:org.syncope.core.persistence.dao.impl.VirSchemaDAOImpl.java
@Override public <T extends AbstractVirAttr> List<T> getAttributes(final AbstractVirSchema virtualSchema, final Class<T> reference) { Query query = entityManager.createQuery( "SELECT e FROM " + reference.getSimpleName() + " e" + " WHERE e.virtualSchema=:schema"); query.setParameter("schema", virtualSchema); return query.getResultList(); }
From source file:br.com.blackhouse.internet.controller.LoginController.java
/** * Returns true if user exist else false * /*from www. java 2 s . c o m*/ * @param userName * user name * @param password * user password * @return true if user exist else false */ @Transactional public Usuario checkLogin(String userName, String password) { if (GenericValidator.isBlankOrNull(userName) || GenericValidator.isBlankOrNull(password)) { logger.log(Level.WARNING, "UserName and Password is null"); return null; } Query query = entityManager.createQuery( "select p from Usuario p where " + "p.userName=:userName and " + "p.password=:password"); query.setParameter("userName", userName); query.setParameter("password", password); Usuario value = null; try { value = (Usuario) query.getSingleResult(); value.setLastLoginDate(GregorianCalendar.getInstance().getTime()); } catch (Exception e) { return null; } return value; }
From source file:cz.fi.muni.pa036.airticketbooking.dao.impl.SeatReservationDaoImpl.java
@Override public List<SeatReservation> getByTicket(Long ticket) { try {// w w w . j a v a 2 s . com Query q = em.createQuery("FROM SeatReservation WHERE ticket_id=:ticket"); q.setParameter("ticket", ticket); List<SeatReservation> planes = q.getResultList(); return Collections.unmodifiableList(planes); } catch (PersistenceException | IllegalArgumentException ex) { throw new DataAccessException(ex.getMessage(), ex) { }; } }