Package org.hibernate.classic

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


    t.commit();
    t = s.beginTransaction();

    s.createSQLQuery( "delete from TRUCK" ).executeUpdate();

    l = s.createQuery("from Vehicle").list();
    assertEquals(l.size(),4);

    Car c = (Car) s.createQuery( "from Car where owner = 'Kirsten'" ).uniqueResult();
    c.setOwner("NotKirsten");
    assertEquals(0,s.getNamedQuery( "native-delete-car" ).setString( 0, "Kirsten" ).executeUpdate());
View Full Code Here


    s.createSQLQuery( "delete from TRUCK" ).executeUpdate();

    l = s.createQuery("from Vehicle").list();
    assertEquals(l.size(),4);

    Car c = (Car) s.createQuery( "from Car where owner = 'Kirsten'" ).uniqueResult();
    c.setOwner("NotKirsten");
    assertEquals(0,s.getNamedQuery( "native-delete-car" ).setString( 0, "Kirsten" ).executeUpdate());
    assertEquals(1,s.getNamedQuery( "native-delete-car" ).setString( 0, "NotKirsten" ).executeUpdate());
   
   
View Full Code Here

   
    assertEquals(0,s.createSQLQuery( "delete from SUV where owner = :owner" ).setString( "owner", "NotThere" ).executeUpdate());
    assertEquals(1,s.createSQLQuery( "delete from SUV where owner = :owner" ).setString( "owner", "Joe" ).executeUpdate());
    s.createSQLQuery( "delete from PICKUP" ).executeUpdate();

    l = s.createQuery("from Vehicle").list();
    assertEquals(l.size(),0);


    t.commit();
    s.close();
View Full Code Here

    data.prepare();

    Session s = openSession();
    Transaction t = s.beginTransaction();

    s.createQuery( "insert into Animal (description, bodyWeight, mother) select description, bodyWeight, mother from Human" ).executeUpdate();

    t.commit();
    t = s.beginTransaction();

    t.commit();
View Full Code Here

    data.prepare();

    Session s = openSession();
    Transaction t = s.beginTransaction();
    try {
      s.createQuery( "insert into Pickup (owner, vin, id) select id, vin, owner from Car" ).executeUpdate();
      fail( "mismatched types did not error" );
    }
    catch( QueryException e ) {
      // expected result
    }
View Full Code Here

    }

    t.commit();
    t = s.beginTransaction();

    s.createQuery( "delete Vehicle" ).executeUpdate();

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

    data.cleanup();
View Full Code Here

    Session s = openSession();
    Transaction t = s.beginTransaction();

    try {
      s.createQuery( "insert into Human (id, bodyWeight) select id, bodyWeight from Lizard" ).executeUpdate();
      fail( "superclass prop insertion did not error" );
    }
    catch( QueryException e ) {
      // expected result
    }
View Full Code Here

    }

    t.commit();
    t = s.beginTransaction();

    s.createQuery( "delete Animal where mother is not null" ).executeUpdate();
    s.createQuery( "delete Animal where father is not null" ).executeUpdate();
    s.createQuery( "delete Animal" ).executeUpdate();

    t.commit();
    s.close();
View Full Code Here

    t.commit();
    t = s.beginTransaction();

    s.createQuery( "delete Animal where mother is not null" ).executeUpdate();
    s.createQuery( "delete Animal where father is not null" ).executeUpdate();
    s.createQuery( "delete Animal" ).executeUpdate();

    t.commit();
    s.close();
View Full Code Here

    t.commit();
    t = s.beginTransaction();

    s.createQuery( "delete Animal where mother is not null" ).executeUpdate();
    s.createQuery( "delete Animal where father is not null" ).executeUpdate();
    s.createQuery( "delete Animal" ).executeUpdate();

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

    data.cleanup();
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.