Package org.olat.core.logging

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


      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

 
  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

  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

  /**
   * 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

      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

          throw new AssertException("Try to close un-committed session");
        }
        hibernateSession.close();
      }
    } catch (HibernateException e) {
      throw new DBRuntimeException("Close Session error.", e);
    } catch (Exception e) {
      throw new DBRuntimeException("Error in dbsession.close: ", e);
    } finally {
      try {
        if (hibernateSession != null) {
          if (hibernateSession.isOpen())  hibernateSession.close();
        }
      } catch (Exception e) {
        // we did our best to close the hibernate session
        throw new DBRuntimeException("in finally of DBSession.java / closeSession(), closesession failed again ", e);
      }
    }
  }
View Full Code Here

                  break;
              }
              session.close();
              logInfo("Transaction Level::::" + lev, null);
            } catch (SQLException e) {
              throw new DBRuntimeException("could not get TransactionIsolationLevel from db", e);
            }
          }
        }
        initializeSession();
        // else we have an DBSession in the current thread, but check if
View Full Code Here

      } catch (Error er) {
        logError("Uncaught Error in DBImpl.commit.catch(Exception).", er);
        throw er;
      } catch (Exception ex) {
        logWarn("Could not rollback transaction after commit!", ex);
        throw new DBRuntimeException("rollback after commit failed", e);
      }
      throw new DBRuntimeException("commit failed, rollback transaction", e);
    }
  }
View Full Code Here

        getTransaction().rollback();
        getData().handleRollback(this);
      }
    } catch (Exception ex) {
      logWarn("Could not rollback transaction!",ex);
      throw new DBRuntimeException("rollback failed", ex);
    }   
  }
View Full Code Here

TOP

Related Classes of org.olat.core.logging.DBRuntimeException

Copyright © 2018 www.massapicom. 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.