Examples of DbRuntimeException


Examples of org.olat.core.logging.DBRuntimeException

      }
    } catch (HibernateException e) {
      String msg = "Find in transaction failed: " + query + " " + e;
      trx.setErrorAndRollback(e);
      setError(e);
      throw new DBRuntimeException(msg, e);
    }
    return li;
  }
View Full Code Here

Examples of org.olat.core.logging.DBRuntimeException

    try {
      q = this.getSession().createQuery(query);
      dbq = new DBQueryImpl(q);
    } catch (HibernateException he) {
      setError(he);
      throw new DBRuntimeException("Error while creating DBQueryImpl: ", he);
    }
    return dbq;
  }
View Full Code Here

Examples of org.olat.core.logging.DBRuntimeException

  void evict(Object object) {
    try {
      getSession().evict(object);     
    } catch (Exception e) {
      setError(e);
      throw new DBRuntimeException("Error in evict() Object from Database. ", e);
    }
  }
View Full Code Here

Examples of org.olat.core.logging.DBRuntimeException

  void refresh(Object object) {
    try{
      getSession().refresh(object);
    } catch(Exception e) {
      setError(e);
      throw new DBRuntimeException("Error in refresh() Object from Database. ", e);
    }
  }
View Full Code Here

Examples of org.olat.core.logging.DBRuntimeException

  Connection getConnection() {
    try {
      return getSession().connection();
    } catch (HibernateException he) {
      setError(he);
      throw new DBRuntimeException("Error in getting sql.Connection.", he);

    }
  }
View Full Code Here

Examples of org.olat.core.logging.DBRuntimeException

      if (Tracing.isDebugEnabled(DBManager.class)) {
        logQuery("delete", new Object[] {value}, new Type[] {type}, query)
      }           
    } catch (HibernateException e) {
      setError(e);
      throw new DBRuntimeException ("Delete error. Query" + query + " Object: " + value, e);
    }
    return deleted;
  }
View Full Code Here

Examples of org.olat.core.logging.DBRuntimeException

 
  int delete(DBTransaction trx, String query, Object value, Type type) { 
    int deleted = 0;
   
    if (trx.isRolledBack() || trx.isCommitted()) { // some program bug
      throw new DBRuntimeException("cannot delete in a transaction that is rolledback or committed " + value);
    }
    try {
      //old: deleted = getSession().delete(query, value, type);
     
      Session si = getSession();
      Query qu = si.createQuery(query);
      qu.setParameter(0, value, type);
      List foundToDel = qu.list();
      int deletionCount = foundToDel.size();
      for (int i = 0; i < deletionCount; i++ ) {
        si.delete( foundToDel.get(i) );
      }
     
      if (Tracing.isDebugEnabled(DBManager.class)) {
        logQuery("delete (trans "+trx.hashCode()+")",new Object[] {value}, new Type[] {type}, query)
      }
    } catch (HibernateException e) { // we have some error
      trx.setErrorAndRollback(e);
      throw new DBRuntimeException ("Could not delete object: " + value, e);
    }
    return deleted;
  }
View Full Code Here

Examples of org.olat.core.logging.DBRuntimeException

  int delete(DBTransaction trx, String query, Object[] values, Type[] types) {
    int deleted = 0;
   
    if (trx.isRolledBack() || trx.isCommitted()) { // some program bug
      throw new DBRuntimeException("cannot delete in a transaction that is rolledback or committed " + values);
    }
    try {
      //old: deleted = getSession().delete(query, values, types);
      Session si = getSession();
      Query qu = si.createQuery(query);
      qu.setParameters(values, types);
      List foundToDel = qu.list();
      int deletionCount = foundToDel.size();
      for (int i = 0; i < deletionCount; i++ ) {
        si.delete( foundToDel.get(i) );
      }
     
      if (Tracing.isDebugEnabled(DBManager.class)) {
        logQuery("delete (trans "+trx.hashCode()+")", values, types, query)
      }     
    } catch (HibernateException e) { // we have some error
      trx.setErrorAndRollback(e);
      throw new DBRuntimeException ("Could not delete object: " + values, e);
    }
    return deleted;
  }
View Full Code Here

Examples of org.olat.core.logging.DBRuntimeException

  /**
   * OLAT-3652: allow clearing of transaction - needed to avoid side-effects of subsequent session usage with error-in-transaction
   */
  protected void clearTransaction() {
    if ( (hibernateSession != null) && hibernateSession.isOpen()) {
      throw new DBRuntimeException("clearTransaction expected session to be closed at this point!");
    }
    trxWrapper = null;
  }
View Full Code Here

Examples of org.olat.core.logging.DBRuntimeException

      try {
        Transaction trx = hibernateSession.beginTransaction();
        trxWrapper = new DBTransaction(trx);
        return trxWrapper;
      } catch (HibernateException e) {
        throw new DBRuntimeException("DBSession - could not begin DBTransaction", e);
      }
    } else {
      throw new DBRuntimeException(
        "Nested transactions are not allowed! "
        + "Don't use atomar hibernate calls but the equvalent version that requires your current transaction object."
        );
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.