Package org.hibernate.classic

Examples of org.hibernate.classic.Session.iterate()


    assertTrue( baz.getFees().size()==2 );

    s = openSession();
    s.delete(baz);
    s.flush();
    assertFalse( s.iterate("from Fee").hasNext() );
    s.connection().commit();
    s.close();

  }
View Full Code Here


      s.find("from Foo foo where repeat( (foo.foo.string || 'foo') || 'bar', 2 ) = 'foo'");
      s.find("from Bar foo where foo.foo.integer is not null and repeat( (foo.foo.string || 'foo') || 'bar', (5+5)/2 ) = 'foo'");
      s.find("from Bar foo where foo.foo.integer is not null or repeat( (foo.foo.string || 'foo') || 'bar', (5+5)/2 ) = 'foo'");
    }
    if (getDialect() instanceof SybaseDialect) { 
      s.iterate("select baz from Baz as baz join baz.fooArray foo group by baz order by sum(foo.float)");
    }

    s.find("from Foo as foo where foo.component.glarch.name is not null");
    s.find("from Foo as foo left outer join foo.component.glarch as glarch where glarch.name = 'foo'");
View Full Code Here

    s.find("from Baz baz left join baz.fooToGlarch join baz.fooSet");
    s.find("from Baz baz left join baz.fooToGlarch join fetch baz.fooSet foo left join fetch foo.foo");

    list = s.find("from Foo foo where foo.string='osama bin laden' and foo.boolean = true order by foo.string asc, foo.component.count desc");
    assertTrue( "empty query", list.size()==0 );
    Iterator iter = s.iterate("from Foo foo where foo.string='osama bin laden' order by foo.string asc, foo.component.count desc");
    assertTrue( "empty iterator", !iter.hasNext() );

    list = s.find("select foo.foo from Foo foo");
    assertTrue( "query", list.size()==1 );
    assertTrue( "returned object", list.get(0)==foo.getFoo() );
View Full Code Here

      }
      s.find("from Foo foo where foo = some(select x from Foo x where x.long > foo.foo.long) and foo.foo.string='baz'");
      s.find("from Foo foo where foo.foo.string='baz' and foo = some(select x from Foo x where x.long > foo.foo.long)");
      s.find("from Foo foo where foo = some(select x from Foo x where x.long > foo.foo.long)");

      s.iterate("select foo.string, foo.date, foo.foo.string, foo.id from Foo foo, Baz baz where foo in elements(baz.fooArray) and foo.string like 'foo'");
    }
    list = s.find("from Foo foo where foo.component.count is null order by foo.component.count");
    assertTrue( "component query", list.size()==0 );
    list = s.find("from Foo foo where foo.component.name='foo'");
    assertTrue( "component query", list.size()==2 );
View Full Code Here

    assertTrue( "by id query", list.size()==1 );
    assertTrue( "by id returned object", list.get(0)==foo.getFoo() );

    s.find( "from Foo foo where foo.foo = ?", foo.getFoo(), Hibernate.entity(Foo.class) );

    assertTrue( !s.iterate("from Bar bar where bar.string='a string' or bar.string='a string'").hasNext() );

    iter = s.iterate(
      "select foo.component.name, elements(foo.component.importantDates) from Foo foo where foo.foo.id=?",
      foo.getFoo().getKey(),
      Hibernate.STRING
View Full Code Here

    s.find( "from Foo foo where foo.foo = ?", foo.getFoo(), Hibernate.entity(Foo.class) );

    assertTrue( !s.iterate("from Bar bar where bar.string='a string' or bar.string='a string'").hasNext() );

    iter = s.iterate(
      "select foo.component.name, elements(foo.component.importantDates) from Foo foo where foo.foo.id=?",
      foo.getFoo().getKey(),
      Hibernate.STRING
    );
    int i=0;
View Full Code Here

      i++;
      Object[] row = (Object[]) iter.next();
      assertTrue( row[0] instanceof String && ( row[1]==null || row[1] instanceof Date ) );
    }
    assertTrue(i==3); //WAS: 4
    iter = s.iterate(
      "select max( elements(foo.component.importantDates) ) from Foo foo group by foo.id"
    );
    assertTrue( iter.next() instanceof Date );

    list = s.find(
View Full Code Here

    list = s.find(" from Bar bar where bar.baz.count=667 and bar.baz.count!=123 and not bar.baz.name='1-E-1'");
    assertTrue( "query many-to-one", list.size()==1 );
    list = s.find(" from Bar i where i.baz.name='Bazza'");
    assertTrue( "query many-to-one", list.size()==1 );

    Iterator rs = s.iterate("select count(distinct foo.foo) from Foo foo");
    assertTrue( "count", ( (Long) rs.next() ).longValue()==2 );
    assertTrue( !rs.hasNext() );
    rs = s.iterate("select count(foo.foo.boolean) from Foo foo");
    assertTrue( "count", ( (Long) rs.next() ).longValue()==2 );
    assertTrue( !rs.hasNext() );
View Full Code Here

    assertTrue( "query many-to-one", list.size()==1 );

    Iterator rs = s.iterate("select count(distinct foo.foo) from Foo foo");
    assertTrue( "count", ( (Long) rs.next() ).longValue()==2 );
    assertTrue( !rs.hasNext() );
    rs = s.iterate("select count(foo.foo.boolean) from Foo foo");
    assertTrue( "count", ( (Long) rs.next() ).longValue()==2 );
    assertTrue( !rs.hasNext() );
    rs = s.iterate("select count(*), foo.int from Foo foo group by foo.int");
    assertTrue( "count(*) group by", ( (Object[]) rs.next() )[0].equals( new Long(3) ) );
    assertTrue( !rs.hasNext() );
View Full Code Here

    assertTrue( "count", ( (Long) rs.next() ).longValue()==2 );
    assertTrue( !rs.hasNext() );
    rs = s.iterate("select count(foo.foo.boolean) from Foo foo");
    assertTrue( "count", ( (Long) rs.next() ).longValue()==2 );
    assertTrue( !rs.hasNext() );
    rs = s.iterate("select count(*), foo.int from Foo foo group by foo.int");
    assertTrue( "count(*) group by", ( (Object[]) rs.next() )[0].equals( new Long(3) ) );
    assertTrue( !rs.hasNext() );
    rs = s.iterate("select sum(foo.foo.int) from Foo foo");
    assertTrue( "sum", ( (Long) rs.next() ).longValue()==4 );
    assertTrue( !rs.hasNext() );
View Full Code Here

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.