Package javax.persistence

Examples of javax.persistence.EntityManager.createNamedQuery()


  // TODO OGM-564 Re-enable once HHH-8237 is resolved and we're on ORM 4.3.6
  public void testProjectionQueryWithTypeConversion() throws Exception {
    begin();
    EntityManager em = createEntityManager();

    List<Byte> result = em.createNamedQuery( "PoemRatings" ).getResultList();
    assertThat( result ).containsOnly( portia.getRating(), athanasia.getRating() );

    commit();
    close( em );
  }
View Full Code Here


  @Test
  public void testMappedEntityResultFromNamedNativeQuery() throws Exception {
    begin();
    EntityManager em = createEntityManager();

    OscarWildePoem poem = (OscarWildePoem) em.createNamedQuery( "AthanasiaQueryWithMapping" ).getSingleResult();

    assertAreEquals( athanasia, poem );

    commit();
    close( em );
View Full Code Here

  public Query createNamedQuery(String arg0)
  {
    EntityManager em = getPersistenceContext(false);
    try {
      return em.createNamedQuery(arg0);
    } finally {
      if(em == detachedManager)
        em.clear();
    }
  }
View Full Code Here

  public <T> TypedQuery<T> createNamedQuery(String arg0, Class<T> arg1)
  {
    EntityManager em = getPersistenceContext(false);
    try {
      return em.createNamedQuery(arg0, arg1);
    } finally {
      if(em == detachedManager)
        em.clear();
    }
  }
View Full Code Here

    public Person findPerson(String userName) {
        EntityManager em = emf.createEntityManager();
        logger.finest("In findPerson for " + userName);
        try {
            Query q = em.createNamedQuery("getUserByName");
            q.setParameter("userName", userName);
            List<Person> users = q.getResultList();
            if (users.size() < 1) {
                logger.warning("Person with username = " + userName + " not found");
                return null;
View Full Code Here

    }

    public List<SocialEvent> getPostedEvents(Person p) {
        EntityManager em = emf.createEntityManager();
        try {
            Query q = em.createNamedQuery("getPostedEvents");
            q.setParameter("submitter", p.getUserName());
            List<SocialEvent> events = q.getResultList();
            return events;
        } finally {
            em.close();
View Full Code Here

    }

    public Collection<Invitation> getIncomingInvitations(Person p) {
        EntityManager em = emf.createEntityManager();
        try {
            Query q = em.createNamedQuery("getIncomingInvitations");
            q.setParameter("candidate", p.getUserName());
            Collection<Invitation> invites = q.getResultList();
            return invites;
        } finally {
            em.close();
View Full Code Here

    }

    public Collection<Invitation> getOutgoingInvitations(Person p) {
        EntityManager em = emf.createEntityManager();
        try {
            Query q = em.createNamedQuery("getOutgoingInvitations");
            q.setParameter("requestor", p.getUserName());
            Collection<Invitation> invites = q.getResultList();
            return invites;
        } finally {
            em.close();
View Full Code Here

     * Get all the groups on this server
     * @return a list of all groups
     */
    public List<GroupEntity> getGroups() {
        EntityManager em = emf.createEntityManager();
        Query q = em.createNamedQuery("getGroups");
        return (List<GroupEntity>) q.getResultList();
    }

    /**
     * Find all groups that match the given search parameters
View Full Code Here

     * @return the groups that match the given parameters, or an empty list
     * if no groups match
     */
    public List<GroupEntity> findGroups(String groupId) {
        EntityManager em = emf.createEntityManager();
        Query q = em.createNamedQuery("findGroups").setParameter("id", groupId);
        return (List<GroupEntity>) q.getResultList();
    }

    /**
     * Get all groups associated with the given member Id
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.