Package javax.persistence

Examples of javax.persistence.EntityManager.createNativeQuery()


            }
        }
        else if (query.isNative())
        {
            String jpqlQuery = context.applyQueryStringPostProcessors(query.value());
            result = params.applyTo(entityManager.createNativeQuery(jpqlQuery));
        }
        else
        {
            String jpqlQuery = context.applyQueryStringPostProcessors(query.value());
            context.setQueryString(jpqlQuery);
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 i set i.descr = 'Logitech Mouse' where i.name = 'Mouse'"
    ).executeUpdate()
    );
    item = em.find( Item.class, item.getName() );
    assertEquals( "Logitech Mouse", item.getDescr() );
View Full Code Here

            start = System.currentTimeMillis();
        try {
            // invoke underlying entity manager method and if not running in a tx
            // return a Query wrapper around the result.
            EntityManager entityManager = getEntityManager();
            return detachQueryNonTxInvocation(entityManager, entityManager.createNativeQuery(sqlString, resultClass));
        } finally {
            if (isTraceEnabled) {
                long elapsed = System.currentTimeMillis() - start;
                ROOT_LOGGER.tracef("createNativeQuery resultClass '%s' took %dms", resultClass.getName(), elapsed);
            }
View Full Code Here

            start = System.currentTimeMillis();
        try {
            // invoke underlying entity manager method and if not running in a tx
            // return a Query wrapper around the result.
            EntityManager entityManager = getEntityManager();
            return detachQueryNonTxInvocation(entityManager, entityManager.createNativeQuery(sqlString, resultSetMapping));
        } finally {
            if (isTraceEnabled) {
                long elapsed = System.currentTimeMillis() - start;
                ROOT_LOGGER.tracef("createNativeQuery took %dms", elapsed);
            }
View Full Code Here

            start = System.currentTimeMillis();
        try {
            // invoke underlying entity manager method and if not running in a tx
            // return a Query wrapper around the result.
            EntityManager entityManager = getEntityManager();
            return detachQueryNonTxInvocation(entityManager, entityManager.createNativeQuery(sqlString));
        } finally {
            if (isTraceEnabled) {
                long elapsed = System.currentTimeMillis() - start;
                ROOT_LOGGER.tracef("createNativeQuery took %dms", elapsed);
            }
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.