/** * 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); }
/** * Returns the {@link OpenJPAEntityManagerFactory} specified by * your OpenJPA defaults. This method will return the same logical factory * for each invocation. */ public static OpenJPAEntityManagerFactory getEntityManagerFactory() { return getEntityManagerFactory(null); }
/** * Returns a new {@link OpenJPAEntityManagerFactory} specified by * <code>name</code> in an XML configuration file at the resource location * <code>resource</code>. If <code>name</code> is <code>null</code>, uses * the first resource found in the specified location, regardless of the * name specified in the XML resource or the name of the jar that the * resource is contained in. If <code>resource</code> is <code>null</code>, * uses the spec-defined <code>META-INF/persistence.xml</code> resource. * This method only resolves {@link OpenJPAEntityManagerFactory} instances. */ public static OpenJPAEntityManagerFactory createEntityManagerFactory (String name, String resource) { return createEntityManagerFactory(name, resource, null); }
/** * Returns the {@link org.apache.openjpa.meta.ClassMetaData} associated with * the persistent object <code>o</code>. */ public static ClassMetaData getMetaData(Object o) { if (o == null) return null; EntityManager em = OpenJPAPersistence.getEntityManager(o); return (em == null) ? null : getMetaData(em, ImplHelper.getManagedInstance(o).getClass()); }
/** * Returns the {@link org.apache.openjpa.meta.ClassMetaData} associated with * the persistent object <code>o</code>. */ public static ClassMetaData getMetaData(Object o) { if (o == null) return null; EntityManager em = OpenJPAPersistence.getEntityManager(o); return (em == null) ? null : getMetaData(em, ImplHelper.getManagedInstance(o).getClass()); }
/** * 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); }
/** * Returns the {@link org.apache.openjpa.meta.ClassMetaData} associated with * the persistent object <code>o</code>. */ public static ClassMetaData getMetaData(Object o) { if (o == null) return null; EntityManager em = OpenJPAPersistence.getEntityManager(o); return (em == null) ? null : getMetaData(em, ImplHelper.getManagedInstance(o).getClass()); }
/** * Returns the {@link OpenJPAEntityManagerFactory} specified by * your OpenJPA defaults. This method will return the same logical factory * for each invocation. */ public static OpenJPAEntityManagerFactory getEntityManagerFactory() { return getEntityManagerFactory(null); }
/** * Returns a new {@link OpenJPAEntityManagerFactory} specified by * <code>name</code> in an XML configuration file at the resource location * <code>resource</code>. If <code>name</code> is <code>null</code>, uses * the first resource found in the specified location, regardless of the * name specified in the XML resource or the name of the jar that the * resource is contained in. If <code>resource</code> is <code>null</code>, * uses the spec-defined <code>META-INF/persistence.xml</code> resource. * This method only resolves {@link OpenJPAEntityManagerFactory} instances. */ public static OpenJPAEntityManagerFactory createEntityManagerFactory (String name, String resource) { return createEntityManagerFactory(name, resource, null); }
public String getConnection() { OpenJPAEntityManager kem = OpenJPAPersistence.cast(entityManager); Connection conn = (Connection) kem.getConnection(); return conn.toString(); }
/** * Returns the {@link org.apache.openjpa.meta.ClassMetaData} associated with * the persistent object <code>o</code>. */ public static ClassMetaData getMetaData(Object o) { if (o == null) return null; EntityManager em = OpenJPAPersistence.getEntityManager(o); return (em == null) ? null : getMetaData(em, ImplHelper.getManagedInstance(o).getClass()); }
/** * Returns the {@link OpenJPAEntityManagerFactory} specified by * your OpenJPA defaults. This method will return the same logical factory * for each invocation. */ public static OpenJPAEntityManagerFactory getEntityManagerFactory() { return getEntityManagerFactory(null); }
/** * Returns a new {@link OpenJPAEntityManagerFactory} specified by * <code>name</code> in an XML configuration file at the resource location * <code>resource</code>. If <code>name</code> is <code>null</code>, uses * the first resource found in the specified location, regardless of the * name specified in the XML resource or the name of the jar that the * resource is contained in. If <code>resource</code> is <code>null</code>, * uses the spec-defined <code>META-INF/persistence.xml</code> resource. * This method only resolves {@link OpenJPAEntityManagerFactory} instances. */ public static OpenJPAEntityManagerFactory createEntityManagerFactory (String name, String resource) { return createEntityManagerFactory(name, resource, null); }
public boolean isDetached(Object o) { OpenJPAEntityManager kem = OpenJPAPersistence.cast(entityManager); return kem.isDetached(o); }
/** * Returns the {@link org.apache.openjpa.meta.ClassMetaData} associated with the * persistent object <code>o</code>. */ public static ClassMetaData getMetaData(Object o) { if (o == null) return null; EntityManager em = OpenJPAPersistence.getEntityManager(o); return (em == null) ? null : getMetaData(em, ImplHelper.getManagedInstance(o).getClass()); }
/** * Returns the {@link OpenJPAEntityManagerFactory} specified by * your OpenJPA defaults. This method will return the same logical factory * for each invocation. */ public static OpenJPAEntityManagerFactory getEntityManagerFactory() { return getEntityManagerFactory(null); }
/** * Returns a new {@link OpenJPAEntityManagerFactory} specified by * <code>name</code> in an XML configuration file at the resource location * <code>resource</code>. If <code>name</code> is <code>null</code>, uses * the first resource found in the specified location, regardless of the * name specified in the XML resource or the name of the jar that the * resource is contained in. If <code>resource</code> is <code>null</code>, * uses the spec-defined <code>META-INF/persistence.xml</code> resource. * This method only resolves {@link OpenJPAEntityManagerFactory} instances. */ public static OpenJPAEntityManagerFactory createEntityManagerFactory (String name, String resource) { return createEntityManagerFactory(name, resource, null); }
public String getConnection() { OpenJPAEntityManager kem = OpenJPAPersistence.cast(entityManager); Connection conn = (Connection) kem.getConnection(); return conn.toString(); }
public void afterDelete(LifecycleEvent lifecycleEvent) { if (disable()) { return; } Object entity = lifecycleEvent.getSource(); if (!hasMappingForEntity(entity.getClass(), Cascade.DELETE)) { return; } try { if (log.isDebugEnabled()) { log.debug("Deleting [" + entity + "]"); } EntityManager em = OpenJPAPersistence.getEntityManager(entity); OpenJPAHelper.getCurrentCompassSession(em).delete(entity); } catch (Exception e) { log.error("Failed while deleting [" + entity + "]", e); if (throwExceptionOnError()) { throw new JpaGpsDeviceException("Failed while deleting [" + entity + "]", e); } } }
/** * Returns the {@link OpenJPAEntityManagerFactory} specified by * your OpenJPA defaults. This method will return the same logical factory * for each invocation. */ public static OpenJPAEntityManagerFactory getEntityManagerFactory() { return getEntityManagerFactory(null); }