/** * 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()); }
/** * 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()); }
/** * 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()); }
public void afterPersist(LifecycleEvent lifecycleEvent) { if (disable()) { return; } Object entity = lifecycleEvent.getSource(); if (!hasMappingForEntity(entity.getClass(), Cascade.CREATE)) { return; } try { if (log.isDebugEnabled()) { log.debug("Creating [" + entity + "]"); } EntityManager em = OpenJPAPersistence.getEntityManager(entity); OpenJPAHelper.getCurrentCompassSession(em).create(entity); } catch (Exception e) { log.error("Failed while creating [" + entity + "]", e); if (throwExceptionOnError()) { throw new JpaGpsDeviceException("Failed while creating [" + entity + "]", e); } } }
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); } } }
public void afterStore(LifecycleEvent lifecycleEvent) { if (disable()) { return; } Object entity = lifecycleEvent.getSource(); if (!hasMappingForEntity(entity.getClass(), Cascade.SAVE)) { return; } try { if (log.isDebugEnabled()) { log.debug("Updating [" + entity + "]"); } EntityManager em = OpenJPAPersistence.getEntityManager(entity); OpenJPAHelper.getCurrentCompassSession(em).save(entity); } catch (Exception e) { log.error("Failed while updating [" + entity + "]", e); if (throwExceptionOnError()) { throw new JpaGpsDeviceException("Failed while updating [" + entity + "]", e); } } }