Package org.hibernate.classic

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


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

    try {
      s.createQuery( "insert into Joiner (name, joinedName) select vin, owner from Car" ).executeUpdate();
      fail( "mapped-join insertion did not error" );
    }
    catch( QueryException e ) {
      // expected result
    }
View Full Code Here


    }

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

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

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

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

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

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

    data.cleanup();
View Full Code Here

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

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

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

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

    s = openSession();
    t = s.beginTransaction();
    PettingZoo pz = ( PettingZoo ) s.createQuery( "from PettingZoo" ).uniqueResult();
    t.commit();
    s.close();

    assertEquals( zoo.getName(), pz.getName() );
    assertTrue( zoo.getId() != pz.getId() );
View Full Code Here

    assertEquals( zoo.getName(), pz.getName() );
    assertTrue( zoo.getId() != pz.getId() );

    s = openSession();
    t = s.beginTransaction();
    s.createQuery( "delete Zoo" ).executeUpdate();
    t.commit();
    s.close();
  }

  public void testInsertWithGeneratedVersionAndId() {
View Full Code Here

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

    IntegerVersioned entity = new IntegerVersioned( "int-vers" );
    s.save( entity );
    s.createQuery( "select id, name, version from IntegerVersioned" ).list();
    t.commit();
    s.close();

    Long initialId = entity.getId();
    int initialVersion = entity.getVersion();
View Full Code Here

    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

    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

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

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

  public void testInsertWithGeneratedTimestampVersion() {
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.