List of usage examples for javax.persistence Query setParameter
Query setParameter(int position, Object value);
From source file:com.june.app.user.repository.jpa.UserRepositoryImpl.java
@Override public UserInfo getUser(String userId) { Query query = this.em.createQuery("SELECT userInfo FROM UserInfo userInfo WHERE userInfo.userId =:userId"); query.setParameter("userId", userId); return (UserInfo) query.getSingleResult(); }
From source file:de.berlios.jhelpdesk.dao.jpa.ArticleCategoryDAOJpa.java
@Transactional(readOnly = false) public void moveUp(final Long categoryId) { this.jpaTemplate.execute(new JpaCallback() { public Object doInJpa(EntityManager em) throws PersistenceException { Query q = em.createNativeQuery("SELECT category_move_up(?1)"); q.setParameter(1, categoryId); q.getSingleResult();/* w w w . ja v a2 s . c om*/ return null; } }); }
From source file:org.fabric3.samples.bigbank.loan.store.persistent.JPAStoreService.java
public LoanRecord findBySSN(String ssn) throws StoreException { try {/*from w w w . ja v a 2 s . co m*/ Query query = em.createQuery("SELECT r FROM LoanRecord r WHERE r.ssn = :ssn"); query.setParameter("ssn", ssn); return (LoanRecord) query.getSingleResult(); } catch (PersistenceException e) { throw new StoreException(e); } }
From source file:com.gerenciaProyecto.DaoImple.UsuarioDaoImpl.java
@Override public Usuario consultaUsuarioLogin(String login) { EntityManager em = getEntityManager(); Usuario usuarioLogin = null;/*from w ww .j a va 2s . c o m*/ try { Query q = em.createQuery("SELECT u FROM Usuario u WHERE u.username = :username"); q.setParameter("username", login); usuarioLogin = (Usuario) q.getSingleResult(); } catch (NoResultException e) { e.printStackTrace(); } return usuarioLogin; }
From source file:com.healthcit.cacure.dao.ModuleDao.java
public BaseModule getByUUID(String uuid) { BaseModule module = null;/*from w ww. j a va2s .c o m*/ Query query = em.createQuery("from BaseModule fe where uuid = :Id"); query.setParameter("Id", uuid); try { module = (BaseModule) query.getSingleResult(); } catch (javax.persistence.NoResultException e) { logger.debug("No object found with uuid " + uuid); } return module; }
From source file:com.sct.descubriendoturuta.service.InsigniaServiceImpl.java
@Override @Transactional/*from w w w . j ava 2 s . c o m*/ public List<Insignia> obtenerInsignias(int usuarioId) { Query query = em.createQuery("select i from Insignia i Where i.usuarioId"); query.setParameter("p", usuarioId); return query.getResultList(); }
From source file:com.brienwheeler.svc.usergroups.impl.UserGroupDao.java
@Override @Transactional(readOnly = true, propagation = Propagation.SUPPORTS) public UserGroup findByNameAndType(String groupName, String groupType) { Query query = entityManager .createQuery("from UserGroup where groupName = :groupName and groupType = :groupType"); query.setParameter("groupName", groupName); query.setParameter("groupType", groupType); return getSingleResultOrNull(query); }
From source file:de.berlios.jhelpdesk.dao.jpa.ArticleCategoryDAOJpa.java
@Transactional(readOnly = false) public void moveDown(final Long categoryId) { this.jpaTemplate.execute(new JpaCallback() { public Object doInJpa(EntityManager em) throws PersistenceException { Query q = em.createNativeQuery("SELECT category_move_down(?1)"); q.setParameter(1, categoryId); q.getSingleResult();/*w w w. ja va 2s. co m*/ return null; } }); }
From source file:gumga.framework.application.GumgaCrudAndQueryNotOnlyTypedRepositoryImpl.java
private void addParam(Query q, Map<String, Object> params) { if (params != null) { params.keySet().stream().forEach(key -> q.setParameter(key, params.get(key))); }/*from w w w . j a v a 2s .c om*/ }
From source file:org.fabric3.samples.bigbank.loan.store.persistent.JPAStoreService.java
public LoanRecord find(long id) throws StoreException { try {/*from w ww . j av a2 s .c om*/ Query query = em.createQuery("SELECT r FROM LoanRecord r WHERE r.id = :number"); query.setParameter("number", id); return (LoanRecord) query.getSingleResult(); } catch (PersistenceException e) { throw new StoreException(e); } }