Package org.hibernate.classic

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


  public void testPersistCollections() throws Exception {
    Session s = openSession();
    Transaction txn = s.beginTransaction();
    assertTrue( ( (Long) s.iterate("select count(*) from Bar").next() ).longValue()==0 );
    assertTrue( s.iterate("select count(*) from Bar b").next().equals( new Long(0) ) );
    assertFalse( s.iterate("from Glarch g").hasNext() );

    Baz baz = new Baz();
    s.save(baz);
    baz.setDefaults();
View Full Code Here


  public void testPersistCollections() throws Exception {
    Session s = openSession();
    Transaction txn = s.beginTransaction();
    assertTrue( ( (Long) s.iterate("select count(*) from Bar").next() ).longValue()==0 );
    assertTrue( s.iterate("select count(*) from Bar b").next().equals( new Long(0) ) );
    assertFalse( s.iterate("from Glarch g").hasNext() );

    Baz baz = new Baz();
    s.save(baz);
    baz.setDefaults();
    baz.setStringArray( new String[] { "stuff" } );
View Full Code Here

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

    s = openSession();
    txn = s.beginTransaction();
    assertTrue( ( (Long) s.iterate("select count(*) from Bar").next() ).longValue()==1 );
    baz = (Baz) ( (Object[]) s.find("select baz, baz from Baz baz").get(0) )[1];
    assertTrue( baz.getCascadingBars().size()==1 );
    //System.out.println( s.print(baz) );
    Foo foo = new Foo();
    s.save(foo);
View Full Code Here

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

    s = openSession();
    txn = s.beginTransaction();
    assertTrue( ( (Long) s.iterate("select count(*) from Bar").next() ).longValue()==1 );
    baz = (Baz) s.find("select baz from Baz baz order by baz").get(0);
    assertTrue( "collection of custom types - added element", baz.getCustoms().size()==4 && baz.getCustoms().get(0)!=null );
    assertTrue ( "component of component in collection", baz.getComponents()[1].getSubcomponent()!=null );
    assertTrue( baz.getComponents()[1].getBaz()==baz );
    assertTrue( "set of objects", ( (FooProxy) baz.getFooSet().iterator().next() ).getKey().equals( foo.getKey() ));
View Full Code Here

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

    s = openSession();
    txn = s.beginTransaction();
    assertTrue( ( (Long) s.iterate("select count(*) from Bar").next() ).longValue()==1 );
    baz = (Baz) s.load(Baz.class, baz.getCode());
    assertTrue( baz.getCascadingBars().size()==1 );
    Bar bar = new Bar();
    Bar bar2 = new Bar();
    s.save(bar); s.save(bar2);
View Full Code Here

    baz = (Baz) s.find("select baz from Baz baz order by baz").get(0);
    assertTrue( baz.getCascadingBars().size()==1 );

    Session s2 = openSession();
    Transaction txn2 = s2.beginTransaction();
    assertTrue( ( (Long) s2.iterate("select count(*) from Bar").next() ).longValue()==3 );
    Baz baz2 = (Baz) s2.find("select baz from Baz baz order by baz").get(0);
    Object o = baz2.getFooComponentToFoo().get( new FooComponent("name", 123, null, null) );
    assertTrue(
      o==baz2.getFooComponentToFoo().get( new FooComponent("nameName", 12, null, null) ) && o!=null
    );
View Full Code Here

    s.close();

    s2.reconnect();
    txn2 = s2.beginTransaction();
    baz = (Baz) s2.load(Baz.class, baz.getCode());
    assertTrue( ( (Long) s2.iterate("select count(*) from Bar").next() ).longValue()==3 );
    s2.delete(baz);
    s2.delete( baz.getTopGlarchez().get( new Character('G') ) );
    s2.delete( baz.getTopGlarchez().get( new Character('H') ) );
    int rows = s2.connection().createStatement().executeUpdate("update " + getDialect().openQuote() + "glarchez" + getDialect().closeQuote() + " set baz_map_id=null where baz_map_index='a'");
    assertTrue(rows==1);
View Full Code Here

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

    s = openSession();
    Iterator iter = s.iterate("from Qux q where q.stuff is null");
    int count=0;
    while ( iter.hasNext() ) {
      Qux q = (Qux) iter.next();
      q.setStuff("foo");
      if (count==0 || count==5) iter.remove();
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.flush();
    s.connection().commit();
    s.close();

    s = openSession();
    Iterator it = s.iterate(
      "SELECT one FROM " +
      One.class.getName() +
      " one ORDER BY one.value ASC"
    );
    int count = 0;
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.