List of usage examples for javax.persistence TypedQuery setParameter
TypedQuery<X> setParameter(int position, Object value);
From source file:rzd.vivc.documentexamination.repository.UserRepositoryImpl.java
@Override ///TODO Typed query public User findWithDependencies(Long userID) { TypedQuery createQuery = em.createQuery("SELECT u FROM User u LEFT JOIN FETCH u.department WHERE u.id=:id", User.class); createQuery.setParameter("id", userID); return (User) createQuery.getResultList().get(0); }
From source file:com.pingdu.dao.licenseDao.LicType_entTypeDao.java
public List<Integer> getLicenceTypeListByEntTypeCode(int entTypeCode) { String jpql = "select l.licTypeCode from LicType_entType l where l.entTypeCode=:entTypeCode"; TypedQuery<Integer> query = em().createQuery(jpql, Integer.class); //query.setHint(QueryHints.RESULT_TYPE, ResultType.Map); query.setParameter("entTypeCode", entTypeCode); return query.getResultList(); }
From source file:example.springdata.jpa.showcase.before.AccountServiceImpl.java
@Override public List<Account> findByCustomer(Customer customer) { TypedQuery<Account> query = em.createQuery("select a from Account a where a.customer = ?1", Account.class); query.setParameter(1, customer); return query.getResultList(); }
From source file:net.triptech.metahive.model.Record.java
/** * Count the records.//from w w w. j a v a2s .c o m * * @param filter the filter * @return the long */ public static long countRecords(final RecordFilter filter) { StringBuilder sql = new StringBuilder("SELECT COUNT(r) FROM Record r"); Map<String, Map<String, Object>> whereParameters = buildWhere(filter); Map<String, Object> variables = new HashMap<String, Object>(); if (whereParameters.size() > 0) { String sqlWhere = whereParameters.keySet().iterator().next(); variables = whereParameters.get(sqlWhere); sql.append(sqlWhere); } TypedQuery<Long> q = entityManager().createQuery(sql.toString(), Long.class); for (String variable : variables.keySet()) { q.setParameter(variable, variables.get(variable)); } return q.getSingleResult(); }
From source file:io.github.todolist.core.repository.impl.UserRepositoryImpl.java
/** * {@inheritDoc}/*w w w. jav a 2 s . c o m*/ */ public User getUserByEmail(final String email) { TypedQuery<User> query = entityManager.createNamedQuery("findUserByEmail", User.class); query.setParameter("p_email", email); List<User> users = query.getResultList(); return (users != null && !users.isEmpty()) ? users.get(0) : null; }
From source file:it.volaconnoi.bean.ReservationManagerBean.java
@Override public List<Reservation> getValidReservation(String id_reservation) { TypedQuery<Reservation> query = em.createNamedQuery("Reservation.findValidReservation", Reservation.class); return query.setParameter("id_reservation", id_reservation).setParameter("status", false).setMaxResults(1) .getResultList();/*from w ww . j ava 2 s .c o m*/ }
From source file:com.jcertif.abj2014.intro.spring.data.before.SpeakerServiceImpl.java
@Override public List<Speaker> findByLastname(String lastname, int page, int pageSize) { TypedQuery<Speaker> query = em.createQuery("select s from Speaker s where s.lastname = ?1", Speaker.class); query.setParameter(1, lastname); query.setFirstResult(page * pageSize); query.setMaxResults(pageSize);/*from www. j av a 2s . com*/ return query.getResultList(); }
From source file:io.github.todolist.core.repository.impl.TodoRepositoryImpl.java
/** * {@inheritDoc}//ww w. j a va 2 s . co m */ public List<Todo> getTodoListByUser(final long userId) { TypedQuery<Todo> query = entityManager.createNamedQuery("findTodosByUser", Todo.class); query.setParameter(1, userId); return query.getResultList(); }
From source file:br.eti.danielcamargo.backend.common.core.business.UsuarioService.java
public Usuario get(Long id) { TypedQuery<Usuario> query = em.createNamedQuery(Usuario.GET_USUARIO_BY_ID, Usuario.class); query.setParameter("id", id); List<Usuario> result = query.getResultList(); return result.isEmpty() ? null : result.get(0); }
From source file:com.expressui.core.dao.security.query.RelatedPermissionsQuery.java
@Override public void setParameters(TypedQuery<Serializable> typedQuery) { if (hasValue(role)) { typedQuery.setParameter("role", role); }//from w ww. j ava 2s .c o m }