Beispiel #1
0
 public <T extends BaseDto> void delete(T entity) throws DaoException {
   startTxn();
   try {
     getEntityManager().remove(entity);
     getEntityManager().getTransaction().commit();
   } catch (IllegalArgumentException e) {
     getEntityManager().getTransaction().rollback();
     e.printStackTrace();
     throw new DaoException("Create Failed: " + e.getMessage());
   } catch (TransactionRequiredException e) {
     getEntityManager().getTransaction().rollback();
     e.printStackTrace();
     throw new DaoException("Update Failed: " + e.getMessage());
   }
 }
Beispiel #2
0
 public <T extends BaseDto> void delete(Class<T> entityClass, Object[] entityids)
     throws DaoException {
   for (Object id : entityids) {
     startTxn();
     //	        getEntityManager().remove(getEntityManager().find(entityClass, id));
     try {
       getEntityManager().remove(getEntityManager().find(entityClass, id));
       getEntityManager().getTransaction().commit();
     } catch (IllegalArgumentException e) {
       getEntityManager().getTransaction().rollback();
       e.printStackTrace();
       throw new DaoException("Create Failed: " + e.getMessage());
     } catch (TransactionRequiredException e) {
       getEntityManager().getTransaction().rollback();
       e.printStackTrace();
       throw new DaoException("Update Failed: " + e.getMessage());
     }
   }
 }
Beispiel #3
0
 public <T extends BaseDto> void update(T entity) throws DaoException {
   startTxn();
   try {
     getEntityManager().merge(entity);
     //        	getEntityManager().flush();
     getEntityManager().getTransaction().commit();
   } catch (TransactionRequiredException e) {
     getEntityManager().getTransaction().rollback();
     e.printStackTrace();
     throw new DaoException("Update Failed: " + e.getMessage());
   } catch (PersistenceException e) {
     getEntityManager().getTransaction().rollback();
     e.printStackTrace();
     throw new DaoException("Update Failed: " + e.getMessage());
   } catch (Exception e) {
     getEntityManager().getTransaction().rollback();
     e.printStackTrace();
     throw new DaoException("Update Failed: " + e.getMessage());
   }
 }