Package org.hibernate.classic

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


    list = s.find("select foo.string, foo.component, foo.id from Bar foo");
    assertTrue ( ( (FooComponent) ( (Object[]) list.get(0) )[1] ).getName().equals("foo") );
    list = s.find("select elements(baz.components) from Baz baz");
    assertTrue( list.size()==2 );
    list = s.find("select bc.name from Baz baz join baz.components bc");
    assertTrue( list.size()==2 );
    //list = s.find("select bc from Baz baz join baz.components bc");

    s.createQuery("from Foo foo where foo.integer < 10 order by foo.string").setMaxResults(12).list();
View Full Code Here


    fooBag.add( new Foo() );
    baz.setFooBag(fooBag);
    s.save(baz);
    s.flush();
    fooBag = baz.getFooBag();
    s.find("from Baz baz left join fetch baz.fooBag");
    assertTrue( Hibernate.isInitialized(fooBag) );
    assertTrue( fooBag==baz.getFooBag() );
    assertTrue( baz.getFooBag().size()==2 );
    s.connection().commit();
    s.close();
View Full Code Here

    s = openSession();
    baz = (Baz) s.load( Baz.class, baz.getCode() );
    Object bag = baz.getFooBag();
    assertFalse( Hibernate.isInitialized(bag) );
    s.find("from Baz baz left join fetch baz.fooBag");
    assertTrue( Hibernate.isInitialized(bag) );
    assertTrue( bag==baz.getFooBag() );
    assertTrue( baz.getFooBag().size()==2 );
    s.delete(baz);
    s.flush();
View Full Code Here

    for ( int i=0; i<5; i++ ) {
      Fee fee = new Fee();
      list.add(fee);
    }
    baz.setFees(list);
    list = s.find("from Foo foo, Baz baz left join fetch baz.fees");
    assertTrue( Hibernate.isInitialized( ( (Baz) ( (Object[]) list.get(0) )[1] ).getFees() ) );
    s.delete(foo);
    s.delete(foo2);
    s.delete(baz);
    s.flush();
View Full Code Here

    s.disconnect();

    s.reconnect();
    tx = s.beginTransaction();
    assertTrue( s.getCurrentLockMode(b)==LockMode.NONE );
    s.find("from Foo foo");
    assertTrue( s.getCurrentLockMode(b)==LockMode.NONE );
    q = s.createQuery("from Foo foo");
    q.setLockMode("foo", LockMode.READ);
    q.list();
    assertTrue( s.getCurrentLockMode(b)==LockMode.READ);
View Full Code Here

    s.save(foo);
    Foo foo2 = new Foo();
    s.save(foo2);
    foo.setFoo(foo2);

    List list = s.find("from Foo foo inner join fetch foo.foo");
    Foo foof = (Foo) list.get(0);
    assertTrue( Hibernate.isInitialized( foof.getFoo() ) );

    list = s.find("from Baz baz left outer join fetch baz.fooToGlarch");
View Full Code Here

    List list = s.find("from Foo foo inner join fetch foo.foo");
    Foo foof = (Foo) list.get(0);
    assertTrue( Hibernate.isInitialized( foof.getFoo() ) );

    list = s.find("from Baz baz left outer join fetch baz.fooToGlarch");

    list = s.find(
      "select foo, bar from Foo foo left outer join foo.foo bar where foo = ?",
      foo,
      Hibernate.entity(Foo.class)
View Full Code Here

    Foo foof = (Foo) list.get(0);
    assertTrue( Hibernate.isInitialized( foof.getFoo() ) );

    list = s.find("from Baz baz left outer join fetch baz.fooToGlarch");

    list = s.find(
      "select foo, bar from Foo foo left outer join foo.foo bar where foo = ?",
      foo,
      Hibernate.entity(Foo.class)
    );
    Object[] row1 = (Object[]) list.get(0);
View Full Code Here

      Hibernate.entity(Foo.class)
    );
    Object[] row1 = (Object[]) list.get(0);
    assertTrue( row1[0]==foo && row1[1]==foo2 );

    s.find("select foo.foo.foo.string from Foo foo where foo.foo = 'bar'");
    s.find("select foo.foo.foo.foo.string from Foo foo where foo.foo = 'bar'");
    s.find("select foo from Foo foo where foo.foo.foo = 'bar'");
    s.find("select foo.foo.foo.foo.string from Foo foo where foo.foo.foo = 'bar'");
    s.find("select foo.foo.foo.string from Foo foo where foo.foo.foo.foo.string = 'bar'");
    if ( ! (getDialect() instanceof HSQLDialect) ) s.find("select foo.string from Foo foo where foo.foo.foo.foo = foo.foo.foo");
View Full Code Here

    );
    Object[] row1 = (Object[]) list.get(0);
    assertTrue( row1[0]==foo && row1[1]==foo2 );

    s.find("select foo.foo.foo.string from Foo foo where foo.foo = 'bar'");
    s.find("select foo.foo.foo.foo.string from Foo foo where foo.foo = 'bar'");
    s.find("select foo from Foo foo where foo.foo.foo = 'bar'");
    s.find("select foo.foo.foo.foo.string from Foo foo where foo.foo.foo = 'bar'");
    s.find("select foo.foo.foo.string from Foo foo where foo.foo.foo.foo.string = 'bar'");
    if ( ! (getDialect() instanceof HSQLDialect) ) s.find("select foo.string from Foo foo where foo.foo.foo.foo = foo.foo.foo");
    s.find("select foo.string from Foo foo where foo.foo.foo = 'bar' and foo.foo.foo.foo = 'baz'");
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.