Examples of createNamedQuery()


Examples of javax.persistence.EntityManager.createNamedQuery()

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

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

    assertAreEquals( athanasia, poem );

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

Examples of javax.persistence.EntityManager.createNamedQuery()

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

    String result = (String) em.createNamedQuery( "AthanasiaProjectionQuery" ).getSingleResult();
    assertThat( result ).isEqualTo( athanasia.getName() );

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

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

Examples of javax.persistence.EntityManager.createNamedQuery()

  @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

Examples of javax.persistence.EntityManager.createNamedQuery()

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

Examples of javax.persistence.EntityManager.createNamedQuery()

  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

Examples of javax.persistence.EntityManager.createNamedQuery()

    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

Examples of javax.persistence.EntityManager.createNamedQuery()

    }

    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

Examples of javax.persistence.EntityManager.createNamedQuery()

    }

    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

Examples of javax.persistence.EntityManager.createNamedQuery()

    }

    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
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.