Package javax.persistence

Examples of javax.persistence.EntityManager.unwrap()


    em.getTransaction().begin();
    Lockable reread = em.createQuery( "from Lockable", Lockable.class )
        .setLockMode( LockModeType.OPTIMISTIC )
        .getSingleResult();
    assertEquals( initial, reread.getVersion() );
    assertTrue( em.unwrap( SessionImpl.class ).getActionQueue().hasBeforeTransactionActions() );
    em.getTransaction().commit();
    em.close();
    assertEquals( initial, reread.getVersion() );

    em = getOrCreateEntityManager();
View Full Code Here


    em.getTransaction().begin();
    Lockable reread = em.createQuery( "from Lockable l", Lockable.class )
        .setHint( AvailableSettings.ALIAS_SPECIFIC_LOCK_MODE+".l", LockModeType.OPTIMISTIC )
        .getSingleResult();
    assertEquals( initial, reread.getVersion() );
    assertTrue( em.unwrap( SessionImpl.class ).getActionQueue().hasBeforeTransactionActions() );
    em.getTransaction().commit();
    em.close();
    assertEquals( initial, reread.getVersion() );

    em = getOrCreateEntityManager();
View Full Code Here

    File testPackage = buildExplicitPar();
    addPackageToClasspath( testPackage );

    EntityManagerFactory emf = Persistence.createEntityManagerFactory( "manager1", new HashMap() );
    EntityManager em = emf.createEntityManager();
    EventListeners eventListeners = em.unwrap( SessionImplementor.class ).getListeners();
    assertEquals(
        "Explicit pre-insert event through hibernate.ejb.event.pre-insert does not work",
        eventListeners.getPreInsertEventListeners().length,
        eventListeners.getPreUpdateEventListeners().length + 1
    );
View Full Code Here

            org.apache.openjpa.persistence.OpenJPAEntityManagerSPI.class,
            org.apache.openjpa.kernel.DelegatingBroker.class,
            org.apache.openjpa.kernel.Broker.class
        };
        for (Class<?> c : validCasts) {
            Object unwrapped = em.unwrap(c);
            assertTrue(c.isInstance(unwrapped));
        }
        em.close();
    }
   
View Full Code Here

       
        Class<?>[] validCasts = new Class[] {
            java.sql.Connection.class
        };
        for (Class<?> c : validCasts) {
            Object unwrapped = em.unwrap(c);
            assertTrue(c.isInstance(unwrapped));
        }
       
        em.close();
    }
View Full Code Here

            null,
        };
        for (Class<?> c : invalidCasts) {
            try {
                em.getTransaction().begin();
                em.unwrap(c);
                fail("Expected to fail to unwarp with invalid " + c);
            } catch (PersistenceException e) {
                EntityTransaction txn = em.getTransaction();
                assertTrue(txn.getRollbackOnly());
                txn.rollback();
View Full Code Here

            org.apache.openjpa.persistence.OpenJPAEntityManagerSPI.class,
            org.apache.openjpa.kernel.DelegatingBroker.class,
            org.apache.openjpa.kernel.Broker.class
        };
        for (Class<?> c : validCasts) {
            Object unwrapped = em.unwrap(c);
            assertTrue(c.isInstance(unwrapped));
        }
        em.close();
    }
   
View Full Code Here

            null,
        };
        for (Class<?> c : invalidCasts) {
            try {
                em.getTransaction().begin();
                em.unwrap(c);
                fail("Expected to fail to unwarp with invalid " + c);
            } catch (PersistenceException e) {
                EntityTransaction txn = em.getTransaction();
                assertTrue(txn.getRollbackOnly());
                txn.rollback();
View Full Code Here

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

            org.apache.openjpa.persistence.OpenJPAEntityManagerSPI.class,
            org.apache.openjpa.kernel.DelegatingBroker.class,
            org.apache.openjpa.kernel.Broker.class
        };
        for (Class<?> c : validCasts) {
            Object unwrapped = em.unwrap(c);
            assertTrue(c.isInstance(unwrapped));
        }
    }
   
    /**
 
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.