Package org.hibernate.classic

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


    s.save(q);
    q.getFoo().setString("foo2");
    //s.flush();
    //s.connection().commit();
    assertTrue(
      s.iterate("from Foo foo where foo.dependent.qux.foo.string = 'foo2'").hasNext()
    );
    s.delete(foo);
    txn.commit();
    s.close();
  }
View Full Code Here


    s.save(foo1);
    foo.setFoo(foo1);
    List l = s.find("select parent, child from Foo parent, Foo child where parent.foo = child");
    assertTrue( "multi-column find", l.size()==1 );

    Iterator rs = s.iterate("select count(distinct child.id), count(distinct parent.id) from Foo parent, Foo child where parent.foo = child");
    Object[] row = (Object[]) rs.next();
    assertTrue( "multi-column count", ( (Long) row[0] ).intValue()==1 );
    assertTrue( "multi-column count", ( (Long) row[1] ).intValue()==1 );
    assertTrue( !rs.hasNext() );
View Full Code Here

    Object[] row = (Object[]) rs.next();
    assertTrue( "multi-column count", ( (Long) row[0] ).intValue()==1 );
    assertTrue( "multi-column count", ( (Long) row[1] ).intValue()==1 );
    assertTrue( !rs.hasNext() );

    rs = s.iterate("select child.id, parent.id, child.long from Foo parent, Foo child where parent.foo = child");
    row = (Object[]) rs.next();
    assertTrue( "multi-column id", row[0].equals( foo.getFoo().getKey() ) );
    assertTrue( "multi-column id", row[1].equals( foo.getKey() ) );
    assertTrue( "multi-column property", row[2].equals( foo.getFoo().getLong() ) );
    assertTrue( !rs.hasNext() );
View Full Code Here

    assertTrue( "multi-column id", row[0].equals( foo.getFoo().getKey() ) );
    assertTrue( "multi-column id", row[1].equals( foo.getKey() ) );
    assertTrue( "multi-column property", row[2].equals( foo.getFoo().getLong() ) );
    assertTrue( !rs.hasNext() );

    rs = s.iterate("select child.id, parent.id, child.long, child, parent.foo from Foo parent, Foo child where parent.foo = child");
    row = (Object[]) rs.next();
    assertTrue(
      foo.getFoo().getKey().equals( row[0] ) &&
      foo.getKey().equals( row[1] ) &&
      foo.getFoo().getLong().equals( row[2] ) &&
View Full Code Here

    txn.commit();
    s.close();
   
    s = openSession();
    txn = s.beginTransaction();
    Iterator iter = s.iterate("select parent, child from Foo parent, Foo child where parent.foo = child and parent.string='a string'");
    int deletions=0;
    while ( iter.hasNext() ) {
      Object[] pnc = (Object[]) iter.next();
      s.delete( pnc[0] );
      s.delete( pnc[1] );
View Full Code Here

    s.flush();
    s.connection().commit();
    s.close();

    s = openSession();
    iter = s.iterate("from Qux q");
    assertTrue( "empty iterator", !iter.hasNext() );
    s.flush();
    s.connection().commit();
    s.close();
  }
View Full Code Here

      s.save(next);
      last.setNext(next);
      last = next;
      last.setOrder( (short) (i+1) );
    }
    Iterator iter = s.iterate("from Glarch g");
    while ( iter.hasNext() ) {
      iter.next();
    }
    List list = s.find("from Glarch g");
    assertTrue( "recursive find", list.size()==6 );
View Full Code Here

    txn.commit();
    s.close();

    s = openSession();
    txn = s.beginTransaction();
    iter = s.iterate("from Glarch g order by g.order asc");
    while ( iter.hasNext() ) {
      GlarchProxy g = (GlarchProxy) iter.next();
      assertTrue( "not null", g!=null );
      iter.remove();
    }
View Full Code Here

      s.save(foo);
      flast.setFoo(foo);
      flast = flast.getFoo();
      flast.setString( "foo" + (i+1) );
    }
    iter = s.iterate("from Foo foo");
    while ( iter.hasNext() ) {
      iter.next();
    }
    list = s.find("from Foo foo");
    assertTrue( "recursive find", list.size()==6 );
View Full Code Here

    txn.commit();
    s.close();

    s = openSession();
    txn = s.beginTransaction();
    iter = s.iterate("from Foo foo order by foo.string asc");
    while ( iter.hasNext() ) {
      BarProxy bar = (BarProxy) iter.next();
      assertTrue( "not null", bar!=null );
      iter.remove();
    }
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.