Package org.odbms

Examples of org.odbms.Query


   */
  public void testDdiscLast3YearsTitleStartWithJohn()
  {
    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


  private static ObjectContainer gtm = GTM.getInstance();

  private void showAlbum()
  {
    try {
      Query query = gtm.query(Album.class);
      query.sortBy("year");

      ObjectSet<Album> items = query.execute();

      int cnt = 0;
      for (Album album : items) {
        System.out.println("  [ALBUM " + album.OID + "] " + album.name + " (" + album.year + ")");
        String albumArtist = "          Artist=";
View Full Code Here

{
  static final ObjectContainer db = GTM.getInstance();

  void query()
  {
    Query q1 = db.query(Info.class);
    ObjectSet<Info> entries = q1.execute();

    int cnt = 0;
    for (Info info : entries) {
      cnt++;
      System.out.println(cnt + " " + info);
    }

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

  public void testDiscStartsWithTHEandAgeLastTenYears()
  {
    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");
    query.constrain("DYEAR", OP.GREATER, 1998);

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

  public void allAritsts()
  {
    Util.enter("QBE: ALL Artists");

    Query query = gtm.query(Artist.class);

    ObjectSet<Artist> artists = query.execute();
    Util.snapshot();

    for (Artist artist : artists) {
      System.out.println("Artist = " + artist.getOID() + " " + artist.getName() + " played=" + artist.getPlayed());
    }
View Full Code Here

  public void artistJohnLennon()
  {
    Util.enter("QBE: Artist.name='John Lennon'");

    Query query = gtm.query(Artist.class);
    query.constrain("name", OP.EQUALS, null, "John Lennon");

    ObjectSet<Artist> artists = query.execute();
    Util.snapshot();

    for (Artist artist : artists) {
      System.out.println("Artist = " + artist.getOID() + " " + artist.getName() + " played=" + artist.getPlayed());
    }

    query.printConstraintInfo();
    Util.leave(artists.size());
  }
View Full Code Here

  }

  public void albumYelloSubmarine()
  {
    Util.enter("QBE: Album.name='YELLOW SUBMARINE");
    Query query = gtm.query(Album.class);
    query.constrain("name", OP.EQUALS, FUNCTION.TO_UPPER, "YELLOW SUBMARINE");

    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 albumYelloSubmarine1970()
  {
    Util.enter("QBE: Album.name='YELLOW SUBMARINE AND yeear=1970");
    Query query = gtm.query(Album.class);
    query.constrain("name", OP.EQUALS, FUNCTION.TO_UPPER, "YELLOW SUBMARINE");
    query.constrain("year", OP.EQUALS, null, "1970");

    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 testRows()
  {
    int cnt = 0;

    Query query = db.query(Disc.class);
    ObjectSet<Disc> discs = query.execute();
    for (Disc disc : discs) {
      cnt++;
      if (disc.getDYEAR() == 2008)
        rows_from_2008++;
    }
View Full Code Here

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

    Query query = db.query(new Predicate<Disc>() {
      public boolean match(Disc disc)
      {
        return disc.getDYEAR() == 2008;
      }
    });
    ObjectSet<Disc> discs = query.execute();
    for (Disc disc : discs) {
      cnt++;
      if (disc.getDYEAR() != 2008)
        fail("Disc DYEAR != 2008");
    }
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.