/** * 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 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); }