Package org.hibernate.classic

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


    t = s.beginTransaction();
    assertTrue( s.createCriteria(Part.class).list().size()==1 ); //there is a where condition on Part mapping
    assertTrue( s.createCriteria(Part.class).add( Restrictions.eq( "id", p1.getId() ) ).list().size()==1 );
    assertTrue( s.createQuery("from Part").list().size()==1 );
    assertTrue( s.createQuery("from Baz baz join baz.parts").list().size()==2 );
    baz = (Baz) s.createCriteria(Baz.class).uniqueResult();
    assertTrue( s.createFilter( baz.getParts(), "" ).list().size()==2 );
    //assertTrue( baz.getParts().size()==1 );
    s.delete( s.get( Part.class, p1.getId() ));
    s.delete( s.get( Part.class, p2.getId() ));
    s.delete(baz);
View Full Code Here


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

    s = openSession();
    t = s.beginTransaction();
    assertTrue( s.createCriteria(Part.class).list().size()==1 ); //there is a where condition on Part mapping
    assertTrue( s.createCriteria(Part.class).add( Restrictions.eq( "id", p1.getId() ) ).list().size()==1 );
    assertTrue( s.createQuery("from Part").list().size()==1 );
    assertTrue( s.createQuery("from Baz baz join baz.moreParts").list().size()==2 );
    baz = (Baz) s.createCriteria(Baz.class).uniqueResult();
    assertTrue( s.createFilter( baz.getMoreParts(), "" ).list().size()==2 );
View Full Code Here

    s.close();

    s = openSession();
    t = s.beginTransaction();
    assertTrue( s.createCriteria(Part.class).list().size()==1 ); //there is a where condition on Part mapping
    assertTrue( s.createCriteria(Part.class).add( Restrictions.eq( "id", p1.getId() ) ).list().size()==1 );
    assertTrue( s.createQuery("from Part").list().size()==1 );
    assertTrue( s.createQuery("from Baz baz join baz.moreParts").list().size()==2 );
    baz = (Baz) s.createCriteria(Baz.class).uniqueResult();
    assertTrue( s.createFilter( baz.getMoreParts(), "" ).list().size()==2 );
    //assertTrue( baz.getParts().size()==1 );
View Full Code Here

    t = s.beginTransaction();
    assertTrue( s.createCriteria(Part.class).list().size()==1 ); //there is a where condition on Part mapping
    assertTrue( s.createCriteria(Part.class).add( Restrictions.eq( "id", p1.getId() ) ).list().size()==1 );
    assertTrue( s.createQuery("from Part").list().size()==1 );
    assertTrue( s.createQuery("from Baz baz join baz.moreParts").list().size()==2 );
    baz = (Baz) s.createCriteria(Baz.class).uniqueResult();
    assertTrue( s.createFilter( baz.getMoreParts(), "" ).list().size()==2 );
    //assertTrue( baz.getParts().size()==1 );
    s.delete( s.get( Part.class, p1.getId() ));
    s.delete( s.get( Part.class, p2.getId() ));
    s.delete(baz);
View Full Code Here

        Session s = openSession();

        Transaction t = s.beginTransaction();
        Componentizable master = getMaster("hibernate", "open sourc%", "open source1");
        Criteria crit = s.createCriteria(Componentizable.class);
        Example ex = Example.create(master).enableLike();
        crit.add(ex);
        List result = crit.list();
        assertNotNull(result);
        assertEquals(1, result.size());
View Full Code Here

        deleteData();
        initData();
        Session s = openSession();
        Transaction t = s.beginTransaction();
        Componentizable master = getMaster("hibernate", null, "ope%");
        Criteria crit = s.createCriteria(Componentizable.class);
        Example ex = Example.create(master).enableLike();

        crit.add(Restrictions.or(Restrictions.not(ex), ex));

        List result = crit.list();
View Full Code Here

        deleteData();
        initData();
        Session s = openSession();
        Transaction t = s.beginTransaction();
        Componentizable master = getMaster("hibernate", null, "ope%");
        Criteria crit = s.createCriteria(Componentizable.class);
        Example ex = Example.create(master).enableLike()
            .excludeProperty("component.subComponent");
        crit.add(ex);
        List result = crit.list();
        assertNotNull(result);
View Full Code Here

        List result = crit.list();
        assertNotNull(result);
        assertEquals(3, result.size());

        master = getMaster("hibernate", "ORM tool", "fake stuff");
        crit = s.createCriteria(Componentizable.class);
        ex = Example.create(master).enableLike()
            .excludeProperty("component.subComponent.subName1");
        crit.add(ex);
        result = crit.list();
        assertNotNull(result);
View Full Code Here

        .list()
        .get(0);
    assertTrue( l.getCountryCode().equals("AU") );
    assertTrue( l.getCity().equals("Melbourne") );
    assertTrue( l.getLocale().equals( Locale.getDefault() ) );
    assertTrue( s.createCriteria(Location.class).add( Restrictions.eq( "streetNumber", new Integer(300) ) ).list().size()==1 );
    s.getTransaction().commit();
    s.close();

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

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

    s = openSession();
    txn = s.beginTransaction();
    list = s.createCriteria(Foo.class)
      .add( Restrictions.eq( "integer", f.getInteger() ) )
      .add( Restrictions.like( "string", f.getString() ) )
      .add( Restrictions.in( "boolean", new Boolean[] { f.getBoolean(), f.getBoolean() } ) )
      .add( Restrictions.isNotNull("foo") )
      .setFetchMode( "foo", FetchMode.JOIN )
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.