List of usage examples for javax.persistence EntityManager createNamedQuery
public <T> TypedQuery<T> createNamedQuery(String name, Class<T> resultClass);
TypedQuery
for executing a Java Persistence query language named query. From source file:com.chiralbehaviors.CoRE.location.LocationNetwork.java
public static List<Relationship> getUsedRelationships(EntityManager em) { return em.createNamedQuery(GET_USED_RELATIONSHIPS, Relationship.class).getResultList(); }
From source file:au.org.ands.vocabs.toolkit.db.TaskUtils.java
/** Get all tasks. * @return A list of Tasks// w w w .j a va 2s. c om */ public static List<Task> getAllTasks() { EntityManager em = DBContext.getEntityManager(); TypedQuery<Task> query = em.createNamedQuery(Task.GET_ALL_TASKS, Task.class); List<Task> tasks = query.getResultList(); em.close(); return tasks; }
From source file:com.github.jinahya.persistence.ShadowTest.java
protected static Shadow FIND_BY_USERNAME(final EntityManager manager, final String username) { try {/* w ww. j a v a 2 s .com*/ return manager.createNamedQuery(Shadow.NQ_FIND_BY_USERNAME, Shadow.class) .setParameter("username", username).getSingleResult(); } catch (NoResultException nre) { } return null; }
From source file:com.github.jinahya.persistence.ShadowTest.java
protected static boolean puthenticate(final EntityManager manager, final String username, final byte[] password) { final Shadow shadow = manager.createNamedQuery(Shadow.NQ_FIND_BY_USERNAME, Shadow.class) .setParameter("username", username).getSingleResult(); if (shadow == null) { return false; }// w ww.ja va 2 s . c om return shadow.puthenticate(shadow, password); }
From source file:au.org.ands.vocabs.toolkit.db.AccessPointUtils.java
/** Get all access points for a version. * @param version The version.//from w ww .ja v a2 s. com * @return The list of access points for this version. */ public static List<AccessPoint> getAccessPointsForVersion(final Version version) { EntityManager em = DBContext.getEntityManager(); TypedQuery<AccessPoint> q = em.createNamedQuery(AccessPoint.GET_ACCESSPOINTS_FOR_VERSION, AccessPoint.class) .setParameter(AccessPoint.GET_ACCESSPOINTS_FOR_VERSION_VERSIONID, version.getId()); List<AccessPoint> aps = q.getResultList(); em.close(); return aps; }
From source file:au.org.ands.vocabs.toolkit.db.AccessPointUtils.java
/** Get all access points of a certain type for a version. * @param version The version./*from ww w.jav a 2 s . c om*/ * @param type The type of access point to look for. * @return The list of access points for this version. */ public static List<AccessPoint> getAccessPointsForVersionAndType(final Version version, final String type) { EntityManager em = DBContext.getEntityManager(); TypedQuery<AccessPoint> q = em .createNamedQuery(AccessPoint.GET_ACCESSPOINTS_FOR_VERSION_AND_TYPE, AccessPoint.class) .setParameter(AccessPoint.GET_ACCESSPOINTS_FOR_VERSION_AND_TYPE_VERSIONID, version.getId()) .setParameter(AccessPoint.GET_ACCESSPOINTS_FOR_VERSION_AND_TYPE_TYPE, type); List<AccessPoint> aps = q.getResultList(); em.close(); return aps; }
From source file:au.org.ands.vocabs.toolkit.db.AccessPointUtils.java
/** Get all access points. * @return A list of AccessPoints/*w ww.jav a2 s.c o m*/ */ public static List<AccessPoint> getAllAccessPoints() { EntityManager em = DBContext.getEntityManager(); TypedQuery<AccessPoint> query = em.createNamedQuery(AccessPoint.GET_ALL_ACCESSPOINTS, AccessPoint.class); List<AccessPoint> aps = query.getResultList(); em.close(); return aps; }
From source file:br.nom.abdon.gastoso.dal.ContasDao.java
public List<Conta> listar(final EntityManager em) { return em.createNamedQuery("Conta.all", Conta.class).getResultList(); }
From source file:br.exemplo.service.PessoaTesteTransactionService.java
@Transactional(propagation = Propagation.SUPPORTS) //utiliza a mesma transao public void pessoasAll() { System.out.println("==== SELECIONA TODOS OS DADOS DA TABELA (2) ======"); EntityManager m = emf.createEntityManager(); List<Pessoa> list = m.createNamedQuery("Pessoa.all", Pessoa.class).getResultList(); for (Pessoa p : list) { System.out.println("ALL >> " + p); }/* ww w . jav a 2s .co m*/ }
From source file:org.exoplatform.task.dao.jpa.StatusDAOImpl.java
@Override public Status findLowestRankStatusByProject(Long projectId) { EntityManager em = getEntityManager(); Query query = em.createNamedQuery("Status.findLowestRankStatusByProject", Status.class); query.setParameter("projectId", projectId); return (Status) query.getSingleResult(); }