Esempio n. 1
0
  private QueryResults execute(AccessMode accessMode)
      throws QueryException, PersistenceException, TransactionNotInProgressException {
    org.exolab.castor.persist.QueryResults results;
    PersistenceQuery query;
    SQLEngine engine;
    QueryResults retVal = null;
    ;

    if (_expr == null && _spCall == null)
      throw new IllegalStateException("Must create query before using it");
    try {
      switch (_projectionType) {
        case ParseTreeWalker.PARENT_OBJECT:
        case ParseTreeWalker.DEPENDANT_OBJECT:
        case ParseTreeWalker.DEPENDANT_OBJECT_VALUE:

          // System.out.println("Executing object query");

          engine = (SQLEngine) _dbEngine.getPersistence(_objClass);
          if (_expr != null) {
            query = engine.createQuery(_expr, _bindTypes);
          } else {
            query = engine.createCall(_spCall, _bindTypes);
            if (query == null) throw new QueryException(Messages.message("query.callNotSupported"));
          }
          if (_bindValues != null) {
            for (int i = 0; i < _bindValues.length; ++i) query.setParameter(i, _bindValues[i]);
          }
          results = _dbImpl.getTransaction().query(_dbEngine, query, accessMode);
          _fieldNum = 0;

          // System.out.println( _projectionType );

          if (_projectionType == ParseTreeWalker.PARENT_OBJECT)
            retVal = new OQLEnumeration(results);
          else retVal = new OQLEnumeration(results, _pathInfo, _clsDesc);
          break;
        case ParseTreeWalker.DEPENDANT_VALUE:
        case ParseTreeWalker.AGGREGATE:
        case ParseTreeWalker.FUNCTION:

          // System.out.println("Executing simple query");

          SimpleQueryExecutor sqe = new SimpleQueryExecutor(_dbImpl);
          retVal = sqe.execute(_expr, _bindValues);
      }
    } catch (PersistenceException except) {
      throw except;
    }
    return (retVal);
  }
Esempio n. 2
0
  /**
   * Constructor.
   *
   * @param engine SQL engine for all persistence operations at entities of the type this class is
   *     responsible for. Holds all required information of the entity type.
   */
  public SQLStatementDelete(final SQLEngine engine) {
    _type = engine.getDescriptor().getJavaClass().getName();
    _tableInfo = engine.getTableInfo();

    buildStatement(new ClassDescriptorJDONature(engine.getDescriptor()).getTableName());
  }