Package org.odbms

Examples of org.odbms.Query


   */
  public void testDdiscLast3YearsWithSingleInTitle()
  {
    final AtomicInteger cnt = new AtomicInteger();

    Query query = db.query(new Predicate<Disc>() {
      public boolean match(Disc disc)
      {
        if (disc.getAge() <= 3 && disc.getAge() != -1) {
          cnt.incrementAndGet();
          return true;
        } else {
          return false;
        }
      }
    });
    query.constrain("DTITLE", OP.STARTS_WITH, "John");

    ObjectSet<Disc> discs = query.execute();
    for (Disc disc : discs) {
      if (disc.getAge() > 3)
        fail("Disc age >3");
      if (!disc.getDTITLE().startsWith("John"))
        fail("DTITLE does not start with 'John'");
View Full Code Here


  public void albumYear1969()
  {
    Util.enter("QBE: Album.year=1969");

    Query query = gtm.query(Album.class);
    query.constrain("year", OP.EQUALS, null, "1969");

    ObjectSet<Album> albums = query.execute();
    Util.snapshot();
    for (Album album : albums) {
      System.out.println("Album " + album.getOID() + " " + album.getName() + " " + album.getYear());
    }
    Util.leave(albums.size());
View Full Code Here

   */
  public void testDiscLast3YearsStartsWithTHEandAgeLastTenYearsAndEndsWithSingle()
  {
    final AtomicInteger cnt = new AtomicInteger();

    Query query = db.query(new Predicate<Disc>() {
      public boolean match(Disc disc)
      {
        if (disc.getAge() < 10 && disc.getAge() != -1) {
          cnt.incrementAndGet();
          return true;
        } else {
          return false;
        }
      }
    });
    query.constrain("DTITLE", OP.STARTS_WITH, "The");

    ObjectSet<Disc> discs = query.execute();
    for (Disc disc : discs) {
      if (disc.getAge() < 10) {
        cnt.decrementAndGet();
      } else {
        fail("Disc age is greater 10 years");
View Full Code Here

   */
  public void testPersonJoeckel()
  {
    int cnt = 0;

    Query query = db.query(Person.class);
    query.constrain("lastName", OP.EQUALS, FUNCTION.TO_UPPER, "joeckel");
    ObjectSet<Person> joeckels = query.execute();
    for (Person p : joeckels) {
      if (!"Lothar".equals(p.getFirstName()) || !"Joeckel".equals(p.getLastName()))
        fail("Invalid data in firstName || lastName");
      cnt++;
    }
View Full Code Here

   * Find all customers with company=CUSTOMER (Customer extends Person)
   */
  public void testCustomerWithName()
  {
    int cnt = 0;
    Query query = db.query(Customer.class);
    query.constrain("companyName", OP.EQUALS, FUNCTION.TO_UPPER, "MI6");
    ObjectSet<Customer> customers = query.execute();
    for (Customer p : customers) {
      if (!"GOLD4712".equals(p.getCustNr()) || !"MI6".equals(p.getCompanyName()))
        fail("Invalid data in custNr || companyName");
      cnt++;
    }
View Full Code Here

      {
        return o1.getAge().compareTo(o2.getAge());
      }
    };

    Query query = db.query(new Predicate<Disc>() {
      public boolean match(Disc disc)
      {
        int age = disc.getAge();
        boolean valid = (age >= 0 && age <= 3);
        if (valid) {
          cnt.incrementAndGet();
          return true;
        } else {
          return false;
        }
      }
    }, compByAge);

    ObjectSet<Disc> discs = query.execute();

    if (cnt.intValue() == 0)
      fail("No rows found");

    int lastAge = -1;
View Full Code Here

      {
        return o1.getAge().compareTo(o2.getAge());
      }
    };

    Query query = db.query(new Predicate<Disc>() {
      public boolean match(Disc disc)
      {
        int age = disc.getAge();
        boolean valid = (age >= 0 && age <= 3) && disc.getDTITLE().contains("Band");
        if (valid) {
          cnt.incrementAndGet();
          return true;
        } else {
          return false;
        }
      }
    }, compByAge);
    query.constrain("DTITLE", OP.CONTAINS, "Band");

    ObjectSet<Disc> discs = query.execute();

    if (cnt.intValue() == 0)
      fail("No rows found");

    for (Disc disc : discs) {
View Full Code Here

   *
   */
  public void testLast3YearsWithJohnInTitle()
  {
    final AtomicInteger cnt = new AtomicInteger();
    Query query = db.query(new Predicate<Disc>() {
      public boolean match(Disc disc)
      {
        int age = disc.getAge();
        boolean valid = (age <= 3 && age != -1);
        if (valid) {
          cnt.incrementAndGet();
          return true;
        } else {
          return false;
        }
      }
    });
    query.constrain("DTITLE", OP.STARTS_WITH, "John");

    ObjectSet<Disc> discs = query.execute();
    int processed = 0;
    for (Disc disc : discs) {
      int age = disc.getAge();
      boolean valid = (age <= 3 && age != -1) && disc.getDTITLE().startsWith("John");
      if (valid)
View Full Code Here

  /**
   *
   */
  public void testAgeOver10StartsWithTHEGenreJazz()
  {
    Query query = db.query(new Predicate<Disc>() {
      public boolean match(Disc disc)
      {
        return disc.getAge() > 10;
      }
    });
    query.constrain("DTITLE", OP.STARTS_WITH, "The");

    Query query2 = db.query(new Predicate<Disc>() {
      public boolean match(Disc disc)
      {
        return disc.getAge() > 10;
      }
    });
    query2.constrain("DGENRE", OP.EQUALS, FUNCTION.TO_UPPER, "JAZZ");

    ObjectSet<Disc> discs = query.AND(query2);

    int processed = 0;
    for (Disc disc : discs) {
View Full Code Here

    });
  }

  private void query()
  {
    Query q1 = db.query(LogEntry.class);
    q1.constrain("date", OP.GREATER, currentTime);

    ObjectSet<LogEntry> entries = q1.execute();

    for (LogEntry entry : entries) {
      System.out.println(entry + " exists=" + entry.getFile().exists());
    }

    q1.printConstraintInfo();
    db.printCacheStatistics();

  }
View Full Code Here

TOP

Related Classes of org.odbms.Query

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.