Examples of createNamedQuery()


Examples of javax.persistence.EntityManager.createNamedQuery()

    }
   
    em = createEntityManager();
   
    try {
      return em.createNamedQuery(sql);
    } finally {
      freeEntityManager(em);
    }
  }
View Full Code Here

Examples of javax.persistence.EntityManager.createNamedQuery()

  public <T> TypedQuery<T> createNamedQuery(String name, Class<T> resultClass)
  {
    EntityManager em = getCurrent();
   
    if (em != null) {
      return em.createNamedQuery(name, resultClass);
    }
   
    em = createEntityManager();
   
    try {
View Full Code Here

Examples of javax.persistence.EntityManager.createNamedQuery()

    }
   
    em = createEntityManager();
   
    try {
      return em.createNamedQuery(name, resultClass);
    } finally {
      freeEntityManager(em);
    }
  }
View Full Code Here

Examples of javax.persistence.EntityManager.createNamedQuery()

     * @throws org.apache.roller.weblogger.WebloggerException on any error
     */
    public Query getNamedQuery(String queryName)
    throws WebloggerException {
        EntityManager em = getEntityManager(false);
        Query q = em.createNamedQuery(queryName);
        // Never flush for queries. Roller code assumes this behavior
        q.setFlushMode(FlushModeType.COMMIT);
        return q;
    }
   
View Full Code Here

Examples of javax.persistence.EntityManager.createNamedQuery()

     * @throws org.apache.roller.weblogger.WebloggerException on any error
     */
    public Query getNamedUpdate(String queryName)
    throws WebloggerException {
        EntityManager em = getEntityManager(true);
        Query q = em.createNamedQuery(queryName);
        return q;
    }
   
    /**
     * Loads properties from given resourceName using given class loader
View Full Code Here

Examples of javax.persistence.EntityManager.createNamedQuery()

  @Test
  public void testIteratorSingleResultFromNamedNativeQuery() 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 testIllegalArgumentExceptionIfQueryDefinitionDoesNotExists() throws Exception {
    thrown.expect( IllegalArgumentException.class );
    EntityManager em = getFactory().createEntityManager();
    em.createNamedQuery( "DoesNotExistsQuery" );
  }

  @Override
  public Class<?>[] getEntities() {
    return new Class<?>[] { Poem.class };
View Full Code Here

Examples of javax.persistence.EntityManager.createNamedQuery()

     * to OPENJPA-2533, the table name in XML was not being picked up.
     */
    public void testNamedQuery() {
        EntityManager em = emf.createEntityManager();

        Query q = em.createNamedQuery("TableNameInXmlEntity.findAll");
        q.getResultList();
        assertContainsSQL(containsSQL);
        assertNotSQL(notContainsSQL);

        em.close();
View Full Code Here

Examples of javax.persistence.EntityManager.createNamedQuery()

        EntityManager em = emf.createEntityManager();

        Query q = em.createQuery("SELECT t FROM TableNameInXmlEntity t");
        q.getResultList();

        q = em.createNamedQuery("TableNameInXmlEntity.findAll");
        q.getResultList();
        assertContainsSQL(containsSQL);
        assertNotSQL(notContainsSQL);

        em.close();
View Full Code Here

Examples of javax.persistence.EntityManager.createNamedQuery()

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

    Long result = (Long) em.createNamedQuery( "CountPoems" ).getSingleResult();
    assertThat( result ).isEqualTo( 2L );

    commit();
    close( em );
  }
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.