/** * Return the OpenJPA-specific variant of {@code EntityManager}. * * @param em the generic {@code EntityManager} instance * @return the OpenJPA-specific variant of {@code EntityManager} */ protected OpenJPAEntityManager getOpenJPAEntityManager(final EntityManager em) { return OpenJPAPersistence.cast(em); }
/** * Return the OpenJPA-specific variant of {@code EntityManager}. * @param em the generic {@code EntityManager} instance * @return the OpenJPA-specific variant of {@code EntityManager} */ protected OpenJPAEntityManager getOpenJPAEntityManager(EntityManager em) { return OpenJPAPersistence.cast(em); }
public String getConnection() { OpenJPAEntityManager kem = OpenJPAPersistence.cast(entityManager); Connection conn = (Connection) kem.getConnection(); return conn.toString(); }
public boolean isDetached(Object o) { OpenJPAEntityManager kem = OpenJPAPersistence.cast(entityManager); return kem.isDetached(o); }
public boolean isDetached(Object o) { OpenJPAEntityManager kem = OpenJPAPersistence.cast(entityManager); return kem.isDetached(o); }
public String getConnection() { OpenJPAEntityManager kem = OpenJPAPersistence.cast(entityManager); Connection conn = (Connection) kem.getConnection(); return conn.toString(); }
protected void createPersistenceUnit() throws ServletException { // START - ALLOW PRINT STATEMENTS try { System.err.println("Creating Standalone Persistent Unit " + _unit); _emf = OpenJPAPersistence.cast(Persistence.createEntityManagerFactory(_unit)); System.err.println("Created Standalone Persistent Unit " + _unit + ":" + _emf); } catch (Exception e) { System.err.println("Can not creating Standalone Persistent Unit " + _unit); e.printStackTrace(); throw new ServletException(_loc.get("no-persistence-unit-standalone", _unit).toString(), e); } // STOP - ALLOW PRINT STATEMENTS }
public boolean isClosed() { OpenJPAEntityManager kem = OpenJPAPersistence.cast(entityManager); Connection conn = (Connection) kem.getConnection(); try { return conn.isClosed(); } catch (SQLException e) { XLog.getLog(getClass()).info(XLog.STD, e.getMessage(), e); } return true; }
public boolean isClosed() { OpenJPAEntityManager kem = OpenJPAPersistence.cast(entityManager); Connection conn = (Connection) kem.getConnection(); try { return conn.isClosed(); } catch (SQLException e) { XLog.getLog(getClass()).info(XLog.STD, e.getMessage(), e); } return true; }
/** * Returns the current Compass session associated with the {@link javax.persistence.EntityManager}. * Compass Session is associated with an Entity Manager when a transaction is started and removed when the * transaction commits/rollsback. * * <p>The session can be used to perform searches that needs to take into account current transactional changes * or to perform additional Compass operations that are not reflected by the mirroring feature. */ public static CompassSession getCurrentCompassSession(EntityManager em) { EntityManager nativeEm = NativeJpaHelper.extractNativeJpa(em); OpenJPAEntityManager openJPAEntityManager = OpenJPAPersistence.cast(nativeEm); return (CompassSession) openJPAEntityManager.getUserObject(CompassProductDerivation.COMPASS_SESSION_USER_OBJECT_KEY); }
/** * Returns the Compass Gps instance associated with the given OpenJPA {@link javax.persistence.EntityManagerFactory}. * Used in order to perform {@link org.compass.gps.device.jpa.embedded.JpaCompassGps#index()} operation. Note, the index * operation should not be perfomed within a running transaction. */ public static JpaCompassGps getCompassGps(EntityManagerFactory emf) { EntityManagerFactory nativeEmf = NativeJpaHelper.extractNativeJpa(emf); OpenJPAEntityManagerFactory openJpaEmf = OpenJPAPersistence.cast(nativeEmf); return (JpaCompassGps) openJpaEmf.getUserObject(CompassProductDerivation.COMPASS_GPS_USER_OBJECT_KEY); }
public void removeLifecycle(EntityManagerFactory entityManagerFactory, JpaGpsDevice device) throws JpaGpsDeviceException { // TODO this should use OpenJPAEnitiyManagerFactorySPI, here for backward compatability with pre 1.0 EntityManagerFactoryImpl emf = (EntityManagerFactoryImpl) OpenJPAPersistence.cast(entityManagerFactory); eventListener = new OpenJPAEventListener(device); emf.removeLifecycleListener(eventListener); } }
/** * Returns the Compass instance assoicated with the given OpenJPA {@link javax.persistence.EntityManagerFactory}. * This allows to get a Compass instnace in order to perform search operations for example outside of a JPA * transaction (for performance reasons, mostly there is no need to start a DB transaction). */ public static Compass getCompass(EntityManagerFactory emf) { EntityManagerFactory nativeEmf = NativeJpaHelper.extractNativeJpa(emf); OpenJPAEntityManagerFactory openJpaEmf = OpenJPAPersistence.cast(nativeEmf); return (Compass) openJpaEmf.getUserObject(CompassProductDerivation.COMPASS_USER_OBJECT_KEY); }
/** * Returns the index settings that are configured within the {@link javax.persistence.EntityManagerFactory} * configuration. Can be used to configure exteranally a {@link org.compass.gps.device.jpa.embedded.JpaCompassGps} * instance. */ public Properties getIndexSettings(EntityManagerFactory emf) { EntityManagerFactory nativeEmf = NativeJpaHelper.extractNativeJpa(emf); OpenJPAEntityManagerFactory openJpaEmf = OpenJPAPersistence.cast(nativeEmf); return (Properties) openJpaEmf.getUserObject(CompassProductDerivation.COMPASS_INDEX_SETTINGS_USER_OBJECT_KEY); }
/** * Returns the Compass instance assoicated with the given OpenJPA {@link javax.persistence.EntityManager}. * This allows to get a Compass instnace in order to perform search operations for example outside of a JPA * transaction (for performance reasons, mostly there is no need to start a DB transaction). */ public static Compass getCompass(EntityManager em) { EntityManager nativeEm = NativeJpaHelper.extractNativeJpa(em); OpenJPAEntityManagerFactory openJpaEmf = OpenJPAPersistence.cast(nativeEm).getEntityManagerFactory(); return (Compass) openJpaEmf.getUserObject(CompassProductDerivation.COMPASS_USER_OBJECT_KEY); }
/** * Returns the Compass Gps instance associated with the given OpenJPA {@link javax.persistence.EntityManager}. * Used in order to perform {@link org.compass.gps.device.jpa.embedded.JpaCompassGps#index()} operation. Note, the index * operation should not be perfomed within a running transaction. */ public static JpaCompassGps getCompassGps(EntityManager em) { EntityManager nativeEm = NativeJpaHelper.extractNativeJpa(em); OpenJPAEntityManagerFactory openJpaEmf = OpenJPAPersistence.cast(nativeEm).getEntityManagerFactory(); return (JpaCompassGps) openJpaEmf.getUserObject(CompassProductDerivation.COMPASS_GPS_USER_OBJECT_KEY); }
/** * Returns the index settings that are configured within the {@link javax.persistence.EntityManager} * configuration. Can be used to configure exteranally a {@link org.compass.gps.device.jpa.embedded.JpaCompassGps} * instnace. */ public Properties getIndexSettings(EntityManager em) { EntityManager nativeEm = NativeJpaHelper.extractNativeJpa(em); OpenJPAEntityManagerFactory openJpaEmf = OpenJPAPersistence.cast(nativeEm).getEntityManagerFactory(); return (Properties) openJpaEmf.getUserObject(CompassProductDerivation.COMPASS_INDEX_SETTINGS_USER_OBJECT_KEY); } }
/** * Returns the {@link org.apache.openjpa.meta.ClassMetaData} associated * with the persistent type <code>cls</code>. */ public static ClassMetaData getMetaData(EntityManager em, Class cls) { if (em == null) throw new NullPointerException("em == null"); OpenJPAEntityManagerSPI kem = (OpenJPAEntityManagerSPI) OpenJPAPersistence.cast(em); try { return kem.getConfiguration().getMetaDataRepositoryInstance(). getMetaData(cls, kem.getClassLoader(), false); } catch (Exception e) { throw PersistenceExceptions.toPersistenceException(e); } }
public WorkflowStore(boolean selectForUpdate) throws StoreException { super(); entityManager = getEntityManager(); javax.xml.validation.Schema schema = Services.get().get(SchemaService.class).getSchema(SchemaName.WORKFLOW); OpenJPAEntityManager kem = OpenJPAPersistence.cast(entityManager); conn = (Connection) kem.getConnection(); this.selectForUpdate = selectForUpdate; }
public WorkflowStore(boolean selectForUpdate) throws StoreException { super(); entityManager = getEntityManager(); javax.xml.validation.Schema schema = Services.get().get(SchemaService.class).getSchema(SchemaName.WORKFLOW); OpenJPAEntityManager kem = OpenJPAPersistence.cast(entityManager); conn = (Connection) kem.getConnection(); this.selectForUpdate = selectForUpdate; }