Package org.hibernate.classic

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


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

    Long initialId = entity.getId();
    //Date initialVersion = entity.getVersion();
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

    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();
  }

  // UPDATES ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
View Full Code Here

  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 ) {
      // ignore : expected behavior
    }
View Full Code Here

                             "where exists (" +
                             "      select f.id " +
                             "      from h.friends f " +
                             "      where f.name.last = 'Public' " +
                             ")";
    int count = s.createQuery( updateQryString ).executeUpdate();
    assertEquals( 1, count );
    s.delete( doll );
    s.delete( joe );
    t.commit();
    s.close();
View Full Code Here

                             "where exists (" +
                             "      select a.id " +
                             "      from e.associatedEntities a " +
                             "      where a.name = 'one-to-many-association' " +
                             ")";
    count = s.createQuery( updateQryString ).executeUpdate();
    assertEquals( 1, count );
    // many-to-many test
    if ( supportsSubqueryOnMutatingTable() ) {
      updateQryString = "update SimpleEntityWithAssociation e " +
                   "set e.name = 'updated' " +
View Full Code Here

                   "where exists (" +
                   "      select a.id " +
                   "      from e.manyToManyAssociatedEntities a " +
                   "      where a.name = 'many-to-many-association' " +
                   ")";
      count = s.createQuery( updateQryString ).executeUpdate();
      assertEquals( 1, count );
    }
    s.delete( entity.getManyToManyAssociatedEntities().iterator().next() );
    s.delete( entity );
    t.commit();
View Full Code Here

    data.prepare();

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

    int count = s.createQuery( "delete Mammal where bodyWeight > 150" ).executeUpdate();
    assertEquals( "Incorrect deletion count on joined subclass", 1, count );

    count = s.createQuery( "delete Mammal" ).executeUpdate();
    assertEquals( "Incorrect deletion count on joined subclass", 1, count );
View Full Code Here

    Transaction t = s.beginTransaction();

    int count = s.createQuery( "delete Mammal where bodyWeight > 150" ).executeUpdate();
    assertEquals( "Incorrect deletion count on joined subclass", 1, count );

    count = s.createQuery( "delete Mammal" ).executeUpdate();
    assertEquals( "Incorrect deletion count on joined subclass", 1, count );

    count = s.createQuery( "delete SubMulti" ).executeUpdate();
    assertEquals( "Incorrect deletion count on joined subclass", 0, count );
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.