Package javax.persistence

Examples of javax.persistence.EntityManager.unwrap()


        try {
            EntityManager em;
            em = getEntityManager();
            em.getTransaction().begin();

            Connection connection = em.unwrap(java.sql.Connection.class); // unwraps the Connection class.
            CallableStatement cs;

            em.getTransaction().commit();

            cs = connection.prepareCall("{call GetSearchedCourses(?, ?)}");
View Full Code Here


                    EntityManager eM = null;
                    eM = getEntityManager();
                    eM.getTransaction().begin();
                   
                    // we are getting the connection string.
                    Connection connection = eM.unwrap(java.sql.Connection.class); // unwraps the Connection class.
                    CallableStatement cs = null;
                   
                    eM.getTransaction().commit();
                   
                   
View Full Code Here

        try {
            EntityManager em;
            em = getEntityManager();
            em.getTransaction().begin();

            Connection connection = em.unwrap(java.sql.Connection.class); // unwraps the Connection class.
            CallableStatement cs;

            em.getTransaction().commit();

            cs = connection.prepareCall("{call GetSemanticCourses(?)}");
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

                    extensionClass = pu.getClassLoader().loadClass(injectionTypeName);
                } catch (ClassNotFoundException e) {
                    throw MESSAGES.cannotLoadFromJpa(e, injectionTypeName);
                }
                // get example of target object
                Object targetValueToInject = entityManager.unwrap(extensionClass);

                // build array of classes that proxy will represent.
                Class[] targetInterfaces = targetValueToInject.getClass().getInterfaces();
                Class[] proxyInterfaces = new Class[targetInterfaces.length + 1]// include extra element for extensionClass
                boolean alreadyHasInterfaceClass = false;
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

            Properties.class,
            null,
        };
        for (Class<?> c : invalidCasts) {
            try {
                em.unwrap(c);
                fail("Expected to fail to unwarp with " + c);
            } catch (Exception e) {
                EntityTransaction txn = em.getTransaction();
                assertFalse(txn.isActive());
            }
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

     */
    protected final <T> NaturalIdQuery<T> createNaturalIdQuery(Class<T> entityType) {
        final EntityManager entityManager = this.getEntityManager();
        final Session session;
        try {
            session = entityManager.unwrap(Session.class);
        }
        catch (IllegalStateException e) {
            throw new IllegalStateException("The DAO Method that calls createNaturalIdQuery must be annotated with @OpenEntityManager or @Transactional", e);
        }
        final NaturalIdLoadAccess naturalIdLoadAccess = session.byNaturalId(entityType);
View Full Code Here

            List<WeakReference<EntityManager>> xpcs = SFSBXPCMap.getINSTANCE().getXPC(handle);
            if (xpcs == null)
                continue;
            for (WeakReference<EntityManager> xpc_ref : xpcs) {
                EntityManager xpc = xpc_ref.get();
                if (xpc != null && xpc.unwrap(EntityManagerMetadata.class).getScopedPuName().equals(puScopedName)) {
                    return xpc;
                }
            }
        }
        return null;
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.