Examples of QueryResults


Examples of org.exolab.castor.jdo.QueryResults

    ProductDetail detail;
    Computer      computer;
    OQLQuery      productOql;
    OQLQuery      groupOql;
    OQLQuery      computerOql;
    QueryResults  results;

    db = _jdo.getDatabase();

    db.begin();
    writer.println( "Begin transaction" );

    // Look up the product and if found in the database,
    // delete this object from the database
    productOql = db.getOQLQuery( "SELECT p FROM myapp.Product p WHERE id = $1" );
    productOql.bind( 4 );
    results = productOql.execute();
    while ( results.hasMore() ) {
      product = (Product) results.next();
      writer.println( "Deleting existing product: " + product );
      db.removeproduct );
    }
       
    // Look up the computer and if found in the database,
    // delete ethis object from the database
    computerOql = db.getOQLQuery( "SELECT c FROM myapp.Computer c WHERE id = $1" );
    computerOql.bind( 6 );
    results = computerOql.execute();
    while ( results.hasMore() ) {
      computer = (Computer) results.next();
      writer.println( "Deleting existing computer: " + computer );
      db.remove( computer );
    }

    // Look up the group and if found in the database,
    // delete this object from the database
    groupOql = db.getOQLQuery( "SELECT g FROM myapp.ProductGroup g WHERE id = $1" );
    groupOql.bind( 3 );
    results = groupOql.execute();
    while ( results.hasMore() ) {
      group = (ProductGroup) results.next();
      writer.println( "Deleting existing group: " + group );
      db.remove( group );
    }
       
    // Checkpoint commits all the updates to the database
    // but leaves the transaction (and locks) open
    writer.println( "Transaction checkpoint" );
    db.commit();

    db.begin();
    // If no such group exists in the database, create a new
    // object and persist it
    groupOql.bind( 3 );
    results = groupOql.execute();
    if ( ! results.hasMore() ) {
      group = new ProductGroup();
      group.setId( 3 );
      group.setName( "a group" );
      db.create( group );
      writer.println( "Creating new group: " + group );
    } else {
      group = (ProductGroup) results.next();
      writer.println( "Query result: " + group );
    }

    // If no such product exists in the database, create a new
    // object and persist it
    // Note: product uses group, so group object has to be
    //       created first, but can be persisted later
    productOql.bind( 4 );
    results = productOql.execute();
    if ( ! results.hasMore() ) {
      product = new Product();
      product.setId( 4 );
      product.setName( "some product" );
      product.setPrice( 55 );
      product.setGroup( group );
      detail = new ProductDetail();
      detail.setId( 1 );
      detail.setName( "one" );
      product.addDetail( detail );
      detail = new ProductDetail();
      detail.setId( 2 );
      detail.setName( "two" );
      product.addDetail( detail );
      writer.println( "Creating new product: " + product );
      db.create( product );
    } else {
      writer.println( "Query result: " + results.next() );
    }

    // If no such computer exists in the database, create a new
    // object and persist it
    // Note: computer uses group, so group object has to be
    //       created first, but can be persisted later
    computerOql.bind( 6 );
    results = computerOql.execute();
    if ( ! results.hasMore() ) {
      computer = new Computer();
      computer.setId( 6 );
      computer.setCpu( "Pentium" );
      computer.setName( "MyPC" );
      computer.setPrice( 300 );
      computer.setGroup( group );
      detail = new ProductDetail();
      detail.setId( 4 );
      detail.setName( "mouse" );
      computer.addDetail( detail );
      detail = new ProductDetail();
      detail.setId( 5 );
      detail.setName( "screen" );
      computer.addDetail( detail );
      writer.println( "Creating new computer: " + computer );
      db.create( computer );
    } else {
      writer.println( "Query result: " + results.next() );
    }
    writer.println( "Commit transaction" );
    db.commit();

    Marshaller     marshaller;

    marshaller = new Marshaller( writer );
    marshaller.setMapping( _mapping );

    db.begin();
    marshaller.marshal( db.load( Product.class, new Integer( 4 ) ) );
    computerOql = db.getOQLQuery( "SELECT c FROM myapp.Computer c" );
    results = computerOql.execute();
    while( results.hasMore() )
      marshaller.marshal( results.next() );
    db.commit();

    db.close();
  }

Examples of org.exolab.castor.persist.QueryResults

            final boolean scrollable)
    throws PersistenceException {
        // Need to execute query at this point. This will result in a
        // new result set from the query, or an exception.
        query.execute(getConnection(engine), accessMode, scrollable);
        return new QueryResults(this, engine, query, accessMode, _db);
    }

Examples of org.fundacionctic.su4j.endpoint.results.QueryResults

  @Override
  public QueryResults getResults() throws BadEndpointInitializationException,
      UnssupportedQueryTypeException, IOException {
    initializeQuery();

    QueryResults queryResults = new QueryResults();
    QueryExecution qe = QueryExecutionFactory.create(this.query, this.datasource);

    if (isSelectQuery()) { // SELECT
      ResultSet results = qe.execSelect();
      queryResults.setType(QueryResultsType.RESULTSET);
      queryResults.setSet(results);
      qe.close();
    } else if (isAskQuery()) { // ASK
      boolean ask = qe.execAsk();
      queryResults.setType(QueryResultsType.BOOLEAN);
      queryResults.setBool(ask);
      qe.close();
    } else if (isDescribeQuery()) { // DESCRIBE   
      Model result = qe.execDescribe();
      //result.setNsPrefixes(model.getNsPrefixMap());
      queryResults.setType(QueryResultsType.MODEL);
      queryResults.setModel(result);
      qe.close();
    } else if (isConstructQuery()) { // CONSTRUCT
      Model result = qe.execConstruct();
      //result.setNsPrefixes(model.getNsPrefixMap());
      queryResults.setType(QueryResultsType.MODEL);
      queryResults.setModel(result);
      qe.close();
    } else {
      logger.error("Unsupported query type");
      throw new UnssupportedQueryTypeException();
    }

Examples of org.jboss.dna.graph.query.QueryResults

     */
    public QueryResults search( final String fullTextSearchExpression,
                                int maxResults,
                                int offset ) {
        FullTextSearchRequest request = requests.search(getCurrentWorkspaceName(), fullTextSearchExpression, maxResults, offset);
        QueryResults results = new org.jboss.dna.graph.query.process.QueryResults(request.getResultColumns(),
                                                                                  request.getStatistics(), request.getTuples());
        return results;
    }

Examples of org.jdbf.engine.sql.QueryResults

    selectCriteria.addSelectEqualTo("groupId",0);
    Criteria criteria = new Criteria("product");
    criteria.addSelectLessThan("OID",13);
    selectCriteria.addAndCriteria(criteria);
    selectCriteria.addOrderBy("OID",true);
    QueryResults results = database.select(repositoryViewName,selectCriteria);
    return results; 
    }

Examples of org.josql.QueryResults

  }
 
  private QueryResults select(String whereClause) throws QueryParseException, QueryExecutionException {
    Query q = new Query ();
    q.parse ("SELECT * FROM " + Pointer.class.getCanonicalName() + "  WHERE " + whereClause);
    QueryResults qr = q.execute (pointers);
    return qr;
  }

Examples of org.josql.QueryResults

  }
 
  private QueryResults selectOrderBy(String whereClause, String orderBy, String limit) throws QueryParseException, QueryExecutionException {
    Query q = new Query ();
    q.parse ("SELECT * FROM " + Pointer.class.getCanonicalName() + "  WHERE " + whereClause + " order by " + orderBy + " " + limit);
    QueryResults qr = q.execute (pointers);
    return qr;
  }

Examples of org.josql.QueryResults

    return qr;
  }
 
  public long collectLFU(int limit) {
    if (limit<=0) limit = pointers.size()/10;
    QueryResults qr;
    try {
      qr = selectOrderBy("free=false", "frequency", "limit 1, " + limit);
      @SuppressWarnings("unchecked")
      List<Pointer> result = qr.getResults();
      return free(result);
    } catch (QueryParseException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (QueryExecutionException e) {

Examples of org.josql.QueryResults

      QueryExecutionException
  {
    Query josqlQuery = prepareQuery(bindVariables, additionalFunctionHandlers);

    josqlQuery.parse(josql);
    QueryResults qr = josqlQuery.execute(queryTarget);

    return qr.getResults();
  }

Examples of org.josql.QueryResults

    josql = josql.replaceFirst(
        fromTargetString,
        fromTargetString.endsWith(FLATTABLE) ? ZNRecordRow.class.getName() : ZNRecord.class
            .getName());
    josqlQuery.parse(josql);
    QueryResults qr = josqlQuery.execute(fromTargetList);
    return qr.getResults();
  }
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.