List of usage examples for javax.persistence Query setParameter
Query setParameter(int position, Object value);
From source file:org.kuali.mobility.configparams.dao.ConfigParamDaoImpl.java
public ConfigParam findConfigParamByName(String name) { Query query = entityManager.createQuery("select cp from ConfigParam cp where cp.name like :name"); query.setParameter("name", name); return (ConfigParam) query.getSingleResult(); }
From source file:org.kuali.mobility.configparams.dao.ConfigParamDaoImpl.java
public void deleteConfigParamById(Long id) { Query query = entityManager.createQuery("delete from ConfigParam cp where cp.configParamId = :id"); query.setParameter("id", id); query.executeUpdate();/* w w w .ja va 2 s . c om*/ }
From source file:org.opentides.dao.impl.UserGroupDaoJpaImpl.java
@SuppressWarnings("unchecked") @Override/*from ww w. java2 s . c om*/ public List<UserGroup> getOldDefaultUserGroups(Long... groupIds) { String queryString = getJpqlQuery("jpql.usergroup.findOldDefault"); Query query = getEntityManager().createQuery(queryString); query.setParameter("groupIds", Arrays.asList(groupIds)); return query.getResultList(); }
From source file:Professor.java
public Professor findProfessor(int empId) { Query q = em.createQuery("SELECT e FROM Professor e WHERE e.id = ?1"); q.setParameter(1, empId); try {/*from w ww . jav a 2 s. c om*/ return (Professor) q.getSingleResult(); } catch (NoResultException e) { return null; } }
From source file:com.exp.tracker.services.impl.GroupServiceImpl.java
@Override @Transactional/*from w w w . j a va 2s .c o m*/ public GroupBean addGroup(GroupBean group) { GroupBean newGb = null; boolean groupExists = true; // first find match Query queryFindMatch = em.createNamedQuery("findGroupMatch"); queryFindMatch.setParameter("groupName", group.getGroupName()); @SuppressWarnings("unused") GroupEntity ge = null; try { ge = (GroupEntity) queryFindMatch.getSingleResult(); } catch (NoResultException nre) { if (logger.isDebugEnabled()) { logger.debug("Group does not exist, thus can be added - " + group.getGroupName()); } groupExists = false; } if (!groupExists) { GroupEntity ge1 = group.getGroupEntity(); Calendar calendar = Calendar.getInstance(); ge1.setCreationDate(calendar.getTime()); ge1.setLastUpdatedDate(calendar.getTime()); em.persist(ge1); if (logger.isDebugEnabled()) { logger.debug("Group added succesfuly - " + group.getGroupName()); } newGb = new GroupBean(ge1); } return newGb; }
From source file:com.pet.demo.repository.jpa.JpaAccountRepositoryImpl.java
public Account findById(int id) { // using 'join fetch' because a single query should load both owners and pets // using 'left join fetch' because it might happen that an owner does not have pets yet Query query = this.em.createQuery("SELECT account FROM Account account WHERE account.id =:id"); query.setParameter("id", id); return (Account) query.getSingleResult(); }
From source file:com.plan.proyecto.repositorios.DaoCuentaImpl.java
@Override public List<Cuenta> findDeQuienSoyAmigoByCuenta(Cuenta cuenta) { Query query = em.createNamedQuery("Cuenta.findDeQuienSoyAmigoByCuenta"); query.setParameter("idorigen", cuenta.getId()); return query.getResultList(); }
From source file:org.mifos.loan.repository.StandardLoanDao.java
@Override @Transactional(readOnly = true)//from w w w. j a v a 2 s .c o m public List<Loan> findLoansForClient(Integer clientId) { Query query = entityManager.createQuery("select loan from Loan loan where loan.clientId = :clientId"); query.setParameter("clientId", clientId); return query.getResultList(); }
From source file:com.excilys.ebi.sample.jpa.query.benchmark.repository.impl.JPQLRepository.java
@Override @SuppressWarnings("unchecked") public List<Song> getSongsBySameArtistOrderBySongTitle(Integer songId) { Query query = em .createQuery("select s2 from Song s1 join s1.artist.songs s2 where s1.id=? order by s2.title"); query.setParameter(1, songId); return query.getResultList(); }
From source file:org.kuali.mobility.configparams.dao.ConfigParamDaoImpl.java
public ConfigParam findConfigParamById(Long id) { Query query = entityManager.createQuery("select cp from ConfigParam cp where cp.configParamId = :id"); query.setParameter("id", id); return (ConfigParam) query.getSingleResult(); }