Package org.hibernate.classic

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


    Long initialId = entity.getId();
    int initialVersion = entity.getVersion();

    s = openSession();
    t = s.beginTransaction();
    int count = s.createQuery( "insert into IntegerVersioned ( name ) select name from IntegerVersioned" ).executeUpdate();
    t.commit();
    s.close();

    assertEquals( "unexpected insertion count", 1, count );
View Full Code Here


    s.close();

    assertEquals( "unexpected insertion count", 1, count );

    s = openSession();
    t = s.beginTransaction();
    IntegerVersioned created = ( IntegerVersioned ) s.createQuery( "from IntegerVersioned where id <> :initialId" )
        .setLong( "initialId", initialId.longValue() )
        .uniqueResult();
    t.commit();
    s.close();
View Full Code Here

    s.close();

    assertEquals( "version was not seeded", initialVersion, created.getVersion() );

    s = openSession();
    t = s.beginTransaction();
    s.createQuery( "delete IntegerVersioned" ).executeUpdate();
    t.commit();
    s.close();
  }
View Full Code Here

        "test bulk inserts with generated id and generated timestamp");
      return;
    }

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

    TimestampVersioned entity = new TimestampVersioned( "int-vers" );
    s.save( entity );
    s.createQuery( "select id, name, version from TimestampVersioned" ).list();
    t.commit();
View Full Code Here

    Long initialId = entity.getId();
    //Date initialVersion = entity.getVersion();

    s = openSession();
    t = s.beginTransaction();
    int count = s.createQuery( "insert into TimestampVersioned ( name ) select name from TimestampVersioned" ).executeUpdate();
    t.commit();
    s.close();

    assertEquals( "unexpected insertion count", 1, count );
View Full Code Here

    s.close();

    assertEquals( "unexpected insertion count", 1, count );

    s = openSession();
    t = s.beginTransaction();
    TimestampVersioned created = ( TimestampVersioned ) s.createQuery( "from TimestampVersioned where id <> :initialId" )
        .setLong( "initialId", initialId.longValue() )
        .uniqueResult();
    t.commit();
    s.close();
View Full Code Here

    assertNotNull( created.getVersion() );
    //assertEquals( "version was not seeded", initialVersion, created.getVersion() );

    s = openSession();
    t = s.beginTransaction();
    s.createQuery( "delete TimestampVersioned" ).executeUpdate();
    t.commit();
    s.close();
  }
View Full Code Here

  // UPDATES ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  public void testIncorrectSyntax() {
    Session s = openSession();
    Transaction t = s.beginTransaction();
    try {
      s.createQuery( "update Human set Human.description = 'xyz' where Human.id = 1 and Human.description is null" );
      fail( "expected failure" );
    }
    catch( QueryException expected ) {
View Full Code Here

  }

  public void testUpdateWithWhereExistsSubquery() {
    // multi-table ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Session s = openSession();
    Transaction t = s.beginTransaction();
    Human joe = new Human();
    joe.setName( new Name( "Joe", 'Q', "Public" ) );
    s.save( joe );
    Human doll = new Human();
    doll.setName( new Name( "Kyu", 'P', "Doll" ) );
View Full Code Here

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

    s = openSession();
    t = s.beginTransaction();
    String updateQryString = "update Human h " +
                             "set h.description = 'updated' " +
                             "where exists (" +
                             "      select f.id " +
                             "      from h.friends f " +
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.