Exemplo n.º 1
0
 public void _delete() {
   try {
     avoidCascadeSaveLoops.set(new HashSet<JPABase>());
     try {
       saveAndCascade(true);
     } finally {
       avoidCascadeSaveLoops.get().clear();
     }
     em().remove(this);
     try {
       em().flush();
     } catch (PersistenceException e) {
       if (e.getCause() instanceof GenericJDBCException) {
         throw new PersistenceException(((GenericJDBCException) e.getCause()).getSQL(), e);
       } else {
         throw e;
       }
     }
     avoidCascadeSaveLoops.set(new HashSet<JPABase>());
     try {
       saveAndCascade(false);
     } finally {
       avoidCascadeSaveLoops.get().clear();
     }
     PlayPlugin.postEvent("JPASupport.objectDeleted", this);
   } catch (PersistenceException e) {
     throw e;
   } catch (Throwable e) {
     throw new RuntimeException(e);
   }
 }
Exemplo n.º 2
0
 public void _save() {
   if (!em().contains(this)) {
     em().persist(this);
     PlayPlugin.postEvent("JPASupport.objectPersisted", this);
   }
   avoidCascadeSaveLoops.set(new HashSet<JPABase>());
   try {
     saveAndCascade(true);
   } finally {
     avoidCascadeSaveLoops.get().clear();
   }
   try {
     em().flush();
   } catch (PersistenceException e) {
     if (e.getCause() instanceof GenericJDBCException) {
       throw new PersistenceException(((GenericJDBCException) e.getCause()).getSQL(), e);
     } else {
       throw e;
     }
   }
   avoidCascadeSaveLoops.set(new HashSet<JPABase>());
   try {
     saveAndCascade(false);
   } finally {
     avoidCascadeSaveLoops.get().clear();
   }
 }