/** * Verify if the JPA provider is EclipseLink. If you are in a container * and not in a transaction this method may incorrectly return false. * It is always more reliable to check isEclipseLink on the EMF or Query. */ public static boolean isEclipseLink(javax.persistence.EntityManager em) { return getEntityManager(em) != null; }
/** * Gets the client session. * * @param em the em * @return the client session */ public AbstractSession getClientSession(EntityManager em) { UnitOfWork uow = JpaHelper.getEntityManager(em).getUnitOfWork(); return (AbstractSession) uow; }
public JPADynamicHelper(EntityManager em) { super(JpaHelper.getEntityManager(em).getDatabaseSession()); }
/** * Gets the client session. * * @param em the em * @return the client session */ public AbstractSession getClientSession(EntityManager em) { UnitOfWork uow = JpaHelper.getEntityManager(em).getUnitOfWork(); return (AbstractSession) uow; }
/** * Create a EclipseLink JPA query dynamically given a EclipseLink query. */ public static Query createQuery(DatabaseQuery query, javax.persistence.EntityManager em) { return getEntityManager(em).createQuery(query); }
public MetamodelImpl(EntityManager em) { // Create a new Metamodel using the EclipseLink session on the EM this(JpaHelper.getEntityManager(em).getAbstractSession()); }
/** * Convert a JPA entityManager into a EclipseLink specific one. This will work * both within a JavaSE deployment as well as within a container where the * EntityManager may be wrapped. * * In the case where the container is not in a transaction it may return null * for its delegate. When this happens the only way to access an EntityManager * is to use the EntityManagerFactory to create a temporary one where the * application manage its lifecycle. */ public static JpaEntityManager getEntityManager(javax.persistence.EntityManager entityManager) { if (entityManager instanceof JpaEntityManager) { return (JpaEntityManager)entityManager; } if (entityManager.getDelegate() != null) { return getEntityManager((javax.persistence.EntityManager)entityManager.getDelegate()); } return null; }
/** * Given an EntityManager return the EntityManagerFactory that created it. This method must be called * on an open entity manager and will return null if called on a closed entityManager. * * This method will return null for non-EclipseLink EntityManagers. * * @see JpaEntityManagerFactory */ public static JpaEntityManagerFactory getEntityManagerFactory(javax.persistence.EntityManager em) { JpaEntityManager entityManager = getEntityManager(em); if (entityManager != null){ if (entityManager.getEntityManagerFactory() != null){ return ((EntityManagerFactoryDelegate)entityManager.getEntityManagerFactory()).getOwner(); } } return null; }