Package javax.persistence

Examples of javax.persistence.EntityManager.createNativeQuery()


   public Query createNativeQuery(String sqlString)
   {
      EntityManager em = getEntityManager();
      if (!factory.isInTx()) em.clear(); // em will be closed by interceptor
      return em.createNativeQuery(sqlString);
   }

   public Query createNativeQuery(String sqlString, Class resultClass)
   {
      EntityManager em = getEntityManager();
View Full Code Here


   public Query createNativeQuery(String sqlString, Class resultClass)
   {
      EntityManager em = getEntityManager();
      if (!factory.isInTx()) em.clear(); // em will be closed by interceptor
      return em.createNativeQuery(sqlString, resultClass);
   }

   public Query createNativeQuery(String sqlString, String resultSetMapping)
   {
      EntityManager em = getEntityManager();
View Full Code Here

   public Query createNativeQuery(String sqlString, String resultSetMapping)
   {
      EntityManager em = getEntityManager();
      if (!factory.isInTx()) em.clear(); // em will be closed by interceptor
      return em.createNativeQuery(sqlString, resultSetMapping);
   }

   public <A> A find(Class<A> entityClass, Object primaryKey)
   {
      EntityManager em = getEntityManager();
View Full Code Here

    em.persist( item );
    assertTrue( em.contains( item ) );
    em.getTransaction().commit();

    em.getTransaction().begin();
    item = (Item) em.createNativeQuery( "select * from Item", Item.class ).getSingleResult();
    assertNotNull( item );
    assertEquals( "Micro$oft mouse", item.getDescr() );
    em.remove( item );
    em.getTransaction().commit();

View Full Code Here

    em.persist( item );
    assertTrue( em.contains( item ) );
    em.getTransaction().commit();

    em.getTransaction().begin();
    item = (Item) em.createNativeQuery( "select name as itemname, descr as itemdescription from Item", "getItem" )
        .getSingleResult();
    assertNotNull( item );
    assertEquals( "Micro$oft mouse", item.getDescr() );
    em.remove( item );
    em.getTransaction().commit();
View Full Code Here

    w.setModel( "Minimic" );
    w.setSerial( "0100202002" );
    em.persist( w );
    em.getTransaction().commit();
    em.getTransaction().begin();
    Query query = em.createNativeQuery( "select * from Wallet w where w.brand = ?", Wallet.class );
    query.setParameter( 1, "Lacoste" );
    w = (Wallet) query.getSingleResult();
    assertNotNull( w );
    em.remove( w );
    em.getTransaction().commit();
View Full Code Here

    em.persist( item );
    assertTrue( em.contains( item ) );
    em.getTransaction().commit();

    em.getTransaction().begin();
    Query query = em.createNativeQuery( "select * from Item where name = ?1", Item.class );
    query.setParameter( 1, "Mouse" );
    item = (Item) query.getSingleResult();
    assertNotNull( item );
    assertEquals( "Micro$oft mouse", item.getDescr() );
    query = em.createNativeQuery( "select * from Item where name = ?", Item.class );
View Full Code Here

    Query query = em.createNativeQuery( "select * from Item where name = ?1", Item.class );
    query.setParameter( 1, "Mouse" );
    item = (Item) query.getSingleResult();
    assertNotNull( item );
    assertEquals( "Micro$oft mouse", item.getDescr() );
    query = em.createNativeQuery( "select * from Item where name = ?", Item.class );
    query.setParameter( 1, "Mouse" );
    item = (Item) query.getSingleResult();
    assertNotNull( item );
    assertEquals( "Micro$oft mouse", item.getDescr() );
    em.remove( item );
View Full Code Here

    em.flush();
    em.clear();

    assertEquals(
        1, em.createNativeQuery(
        "update Item set descr = 'Logitech Mouse' where name = 'Mouse'"
    ).executeUpdate()
    );
    item = em.find( Item.class, item.getName() );
    assertEquals( "Logitech Mouse", item.getDescr() );
View Full Code Here

   public Query createNativeQuery(String sqlString)
   {
      EntityManager em = getEntityManager();
      if (!factory.isInTx()) em.clear(); // em will be closed by interceptor
      return em.createNativeQuery(sqlString);
   }

   public Query createNativeQuery(String sqlString, Class resultClass)
   {
      EntityManager em = getEntityManager();
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.