Package org.odbms

Examples of org.odbms.Query


  }

  private void query()
  {
    Query q1 = db.query(LogEntry.class);
    // q1.constrain("date", OP.GREATER, currentTime);
    q1.constrain("date", OP.RANGE, e1.getDate().getTime(), e2.getDate().getTime());

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

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

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

  }
View Full Code Here


  /**
   *
   */
  POQQuery1OR() {
    Query q1 = gtm.query(Disc.class);
    q1.constrain("DTITLE", OP.STARTS_WITH, FUNCTION.TO_UPPER, "TINA");
    q1.constrain("DTITLE", OP.CONTAINS, FUNCTION.TO_UPPER, "TURNER");

    Query q2 = gtm.query(Disc.class);
    q2.constrain("DTITLE", OP.STARTS_WITH, FUNCTION.TO_UPPER, "IKE");
    q2.constrain("DTITLE", OP.CONTAINS, FUNCTION.TO_UPPER, "TURNER");

    ObjectSet<Disc> discs = q1.OR(q2);

    Util.printObjectSet(discs);

    q1.printConstraintInfo();
    q2.printConstraintInfo();
    gtm.printCacheStatistics();
  }
View Full Code Here

  /**
   *
   */
  public POQQuery1AND() {
    Query q1 = gtm.query(Disc.class);
    q1.constrain("DTITLE", OP.STARTS_WITH, FUNCTION.TO_UPPER, "ERIC CLAPTON");
    q1.constrain("DYEAR", OP.RANGE, 1990, 1999);

    Query q2 = gtm.query(Disc.class);
    q2.constrain("DGENRE", OP.EQUALS, FUNCTION.TO_UPPER, "Blues");
    q2.constrain("DTITLE", OP.CONTAINS, FUNCTION.TO_UPPER, "Live");

    ObjectSet<Disc> discs = q1.AND(q2);

    Util.printObjectSet(discs);

    q1.printConstraintInfo();
    q2.printConstraintInfo();
    gtm.printCacheStatistics();
  }
View Full Code Here

   */
  public POQQuery1(String searchFor) {
    if (searchFor == null)
      throw new IllegalArgumentException("Parameter 'searchFor' must not be null");

    Query q1 = gtm.query(Disc.class);
    q1.constrain("DGENRE", OP.EQUALS, FUNCTION.TO_UPPER, "Jazz");
    q1.constrain("DTITLE", OP.CONTAINS, FUNCTION.TO_UPPER, searchFor);
    q1.constrain("DYEAR", OP.GREATER, 1999);
    q1.sortBy("DYEAR");
    ObjectSet<Disc> discs = q1.execute();

    Util.printObjectSet(discs);
    q1.printConstraintInfo();
    gtm.printCacheStatistics();

    System.out.println("-----------------------------------------");

    // 2. query with Iterator
    Query q2 = gtm.query(Disc.class);
    q2.constrain("DTITLE", OP.STARTS_WITH, FUNCTION.TO_UPPER, searchFor);
    q2.constrain("DTITLE", OP.CONTAINS, FUNCTION.TO_UPPER, "live");
    q2.constrain("DYEAR", OP.RANGE, 2000, 2002);
    q2.constrain("DGENRE", OP.EQUALS, FUNCTION.TO_UPPER, "BLUES");
    discs = q2.execute();

    Iterator<Disc> iter = discs.iterator();
    while (iter.hasNext()) {
      Disc disc = iter.next();
      System.out.println(disc);
    }

    q2.printConstraintInfo();
    gtm.printCacheStatistics();
  }
View Full Code Here

   *
   * @param searchFor
   */
  public void testSorted()
  {
    Query q1 = db.query(Disc.class);
    q1.constrain("DTITLE", OP.CONTAINS, FUNCTION.TO_UPPER, "the");
    q1.constrain("DYEAR", OP.RANGE, 2000, 2009);

    q1.sortBy("DTITLE");
    q1.sortBy("DGENRE");
    q1.sortByDescending("DYEAR");

    ObjectSet<Disc> discs = q1.execute();
    int discsSize = discs.size();

    int age = Integer.MIN_VALUE;
    for (Disc disc : discs) {
      if (age < disc.getAge()) {
View Full Code Here

    super.setUp();
  }

  public void testBandsWithArtist()
  {
    Query query = db.query(new Predicate<Band>() {
      public boolean match(Band band)
      {
        return band.getAritsts().size() > 2;
      }
    });
    ObjectSet<Band> bands = query.execute();
  }
View Full Code Here

  /**
   *
   */
  public void artists()
  {
    Query query = db.query(new Predicate<Artist>() {
      public boolean match(Artist artist)
      {
        return artist.getName().equals("John Lennon");
      }
    });
    ObjectSet<Band> artists = query.execute();
  }
View Full Code Here

  /**
   *
   */
  public void testAlbumWithClock()
  {
    Query query = db.query(new Predicate<Album>() {
      public boolean match(Album album)
      {
        return album.getName().startsWith("Clock");
      }
    });
    ObjectSet<Album> albums = query.execute();

    for (Album album : albums) {
    }
  }
View Full Code Here

  /**
   *
   */
  public void testTrackNameContainsRoad()
  {
    Query query = db.query(new Predicate<Track>() {
      public boolean match(Track track)
      {
        return track.getTitle().contains("road");
      }
    });
    ObjectSet<Track> tracks = query.execute();
  }
View Full Code Here

     */
    public void testWithFakedQuery()
    {
        try
        {
            Query q = broker.query();
            // we are faking a soda query here:
            ((QueryImpl) q).setOjbQuery(ojbQuery());
            int limit = 13;
            q.limitSize(limit);
            ObjectSet oSet = q.execute();
            logger.info("Size of ObjectSet: " + oSet.size());
            assertEquals(limit,oSet.size());
            int count = 0;
            while (oSet.hasNext())
            {
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.