Package org.hibernate.classic

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


    t.commit();
    s.close();

    s = openSession();
    t = s.beginTransaction();
    List l = s.find( "from E e, A a where e.reverse = a.forward and a = ?", a, Hibernate.entity(A.class) );
    assertTrue( l.size()==1 );
    l = s.createQuery( "from E e join fetch e.reverse" ).list();
    assertTrue( l.size()==2 );
    t.commit();
    s.close();
View Full Code Here


    s = openSession();
    txn = s.beginTransaction();
    m = (Master) s.load( Master.class, mid );
    assertTrue( ( (Detail) m.getMoreDetails().iterator().next() ).getSubDetails().size()!=0 );
    s.delete(m);
    assertTrue( s.find("from SubDetail").size()==0 );
    assertTrue( s.find("from Detail d").size()==0 );
    s.delete( s.load(Master.class, m0id) );
    txn.commit();
    s.close();
  }
View Full Code Here

    txn = s.beginTransaction();
    m = (Master) s.load( Master.class, mid );
    assertTrue( ( (Detail) m.getMoreDetails().iterator().next() ).getSubDetails().size()!=0 );
    s.delete(m);
    assertTrue( s.find("from SubDetail").size()==0 );
    assertTrue( s.find("from Detail d").size()==0 );
    s.delete( s.load(Master.class, m0id) );
    txn.commit();
    s.close();
  }
View Full Code Here

    sev = (Several) s.load( Several.class, sev );
    t.commit();
    s.close();
    s = openSession();
    t = s.beginTransaction();
    s.find("from Several");
    t.commit();
    s.close();
    s = openSession();
    t = s.beginTransaction();
    s.delete("from Single");
View Full Code Here

    if ( !(getDialect() instanceof MySQLDialect) && !(getDialect() instanceof SAPDBDialect) && !(getDialect() instanceof MckoiDialect) ) {
      s.iterate("FROM Master m WHERE NOT EXISTS ( FROM m.details d WHERE NOT d.i=5 )");
      s.iterate("FROM Master m WHERE NOT 5 IN ( SELECT d.i FROM m.details AS d )");
    }
    s.iterate("SELECT m FROM Master m JOIN m.details d WHERE d.i=5");
    s.find("SELECT m FROM Master m JOIN m.details d WHERE d.i=5");
    s.find("SELECT m.id FROM Master AS m JOIN m.details AS d WHERE d.i=5");
    t.commit();
    s.close();
  }
View Full Code Here

      s.iterate("FROM Master m WHERE NOT EXISTS ( FROM m.details d WHERE NOT d.i=5 )");
      s.iterate("FROM Master m WHERE NOT 5 IN ( SELECT d.i FROM m.details AS d )");
    }
    s.iterate("SELECT m FROM Master m JOIN m.details d WHERE d.i=5");
    s.find("SELECT m FROM Master m JOIN m.details d WHERE d.i=5");
    s.find("SELECT m.id FROM Master AS m JOIN m.details AS d WHERE d.i=5");
    t.commit();
    s.close();
  }

  public void testMasterDetail() throws Exception {
View Full Code Here

    master.addDetail(d1);
    master.addDetail(d2);
    if ( !(getDialect() instanceof MySQLDialect) && !(getDialect() instanceof Oracle9Dialect) && !(getDialect() instanceof SAPDBDialect) && !(getDialect() instanceof MckoiDialect) && !(getDialect() instanceof org.hibernate.dialect.TimesTenDialect)) {
      assertTrue(
        "query",
        s.find("from Detail d, Master m where m = d.master and size(m.outgoing) = 0 and size(m.incoming) = 0").size()==2
      );
    }
    t.commit();
    s.close();
View Full Code Here

    t.commit();
    s.close();

    s = openSession();
    t = s.beginTransaction();
    assertTrue( s.find("select elements(master.details) from Master master").size()==2 );
    t.commit();
    s.close();

    s = openSession();
    t = s.beginTransaction();
View Full Code Here

    t.commit();
    s.close();

    s = openSession();
    t = s.beginTransaction();
    List list = s.find("from Master m left join fetch m.details");
    Master m = (Master) list.get(0);
    assertTrue( Hibernate.isInitialized( m.getDetails() ) );
    assertTrue( m.getDetails().size()==2 );
    list = s.find("from Detail d inner join fetch d.master");
    Detail dt = (Detail) list.get(0);
View Full Code Here

    t = s.beginTransaction();
    List list = s.find("from Master m left join fetch m.details");
    Master m = (Master) list.get(0);
    assertTrue( Hibernate.isInitialized( m.getDetails() ) );
    assertTrue( m.getDetails().size()==2 );
    list = s.find("from Detail d inner join fetch d.master");
    Detail dt = (Detail) list.get(0);
    Serializable dtid = s.getIdentifier(dt);
    assertTrue( dt.getMaster()==m );

    //assertTrue(m.getAllDetails().size()==2);
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.