Package org.hibernate.classic

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


    s.close();
  }

  public void testTempTableGenerationIsolation() throws Throwable{
    Session s = openSession();
    s.beginTransaction();

    Truck truck = new Truck();
    truck.setVin( "123t" );
    truck.setOwner( "Steve" );
    s.save( truck );
View Full Code Here


    s.getTransaction().rollback();
    s.close();

    s = openSession();
    s.beginTransaction();
    List list = s.createQuery( "from Car" ).list();
    assertEquals( "temp table gen caused premature commit", 0, list.size() );
    s.createQuery( "delete from Car" ).executeUpdate();
    s.getTransaction().rollback();
    s.close();
View Full Code Here

  public void testBooleanHandling() {
    TestData data = new TestData();
    data.prepare();

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

    // currently, we need the three different binds because they are different underlying types...
    int count = s.createQuery( "update BooleanLiteralEntity set yesNoBoolean = :b1, trueFalseBoolean = :b2, zeroOneBoolean = :b3" )
        .setBoolean( "b1", true )
        .setBoolean( "b2", true )
View Full Code Here

  public void testSimpleInsert() {
    TestData data = new TestData();
    data.prepare();

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

    s.createQuery( "insert into Pickup (id, vin, owner) select id, vin, owner from Car" ).executeUpdate();
   
    t.commit();
    t = s.beginTransaction();
View Full Code Here

    Transaction t = s.beginTransaction();

    s.createQuery( "insert into Pickup (id, vin, owner) select id, vin, owner from Car" ).executeUpdate();
   
    t.commit();
    t = s.beginTransaction();

    s.createQuery( "delete Vehicle" ).executeUpdate();
   
    t.commit();
    s.close();
View Full Code Here

  public void testSimpleNativeSQLInsert() {
    TestData data = new TestData();
    data.prepare();

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

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

    s.createSQLQuery( "insert into PICKUP (id, vin, owner) select id, vin, owner from Car" ).executeUpdate();
View Full Code Here

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

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

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

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

  public void testInsertWithManyToOne() {
    TestData data = new TestData();
    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();
View Full Code Here

    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();
    s.close();

    data.cleanup();
View Full Code Here

  public void testInsertWithMismatchedTypes() {
    TestData data = new TestData();
    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 ) {
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.