Package org.hibernate.classic

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


    assertEquals( "Incorrect discrim subclass update count", 1, count );

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

    count = s.createQuery( "update PettingZoo pz set pz.name = pz.name where pz.id = :id" )
        .setLong( "id", data.pettingZoo.getId().longValue() )
        .executeUpdate();
    assertEquals( "Incorrect discrim subclass update count", 1, count );

    t.rollback();
View Full Code Here


    assertEquals( "Incorrect discrim subclass update count", 1, count );

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

    count = s.createQuery( "update Zoo as z set z.name = z.name" ).executeUpdate();
    assertEquals( "Incorrect discrim subclass update count", 2, count );

    t.rollback();
    t = s.beginTransaction();
View Full Code Here

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

    // TODO : not so sure this should be allowed.  Seems to me that if they specify an alias,
    // property-refs should be required to be qualified.
    count = s.createQuery( "update Zoo as z set name = name where id = :id" )
        .setLong( "id", data.zoo.getId().longValue() )
        .executeUpdate();
    assertEquals( "Incorrect discrim subclass update count", 1, count );

    t.commit();
View Full Code Here

    TestData data = new TestData();
    data.prepare();

    Session s = openSession();
    Transaction t = s.beginTransaction();
    int count = s.createQuery( "update Animal set description = description where description = :desc" )
        .setString( "desc", data.frog.getDescription() )
        .executeUpdate();
    assertEquals( "Incorrect entity-updated count", 1, count );

    count = s.createQuery( "update Animal set description = :newDesc where description = :desc" )
View Full Code Here

    int count = s.createQuery( "update Animal set description = description where description = :desc" )
        .setString( "desc", data.frog.getDescription() )
        .executeUpdate();
    assertEquals( "Incorrect entity-updated count", 1, count );

    count = s.createQuery( "update Animal set description = :newDesc where description = :desc" )
        .setString( "desc", data.polliwog.getDescription() )
        .setString( "newDesc", "Tadpole" )
        .executeUpdate();
    assertEquals( "Incorrect entity-updated count", 1, count );
View Full Code Here

    assertEquals( "Incorrect entity-updated count", 1, count );

    Animal tadpole = ( Animal ) s.load( Animal.class, data.polliwog.getId() );
    assertEquals( "Update did not take effect", "Tadpole", tadpole.getDescription() );

    count = s.createQuery( "update Animal set bodyWeight = bodyWeight + :w1 + :w2" )
        .setDouble( "w1", 1 )
        .setDouble( "w2", 2 )
        .executeUpdate();
    assertEquals( "incorrect count on 'complex' update assignment", count, 6 );
View Full Code Here

        .executeUpdate();
    assertEquals( "incorrect count on 'complex' update assignment", count, 6 );

    if ( ! ( getDialect() instanceof MySQLDialect ) ) {
      // MySQL does not support (even un-correlated) subqueries against the update-mutating table
      s.createQuery( "update Animal set bodyWeight = ( select max(bodyWeight) from Animal )" )
          .executeUpdate();
    }

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

    data.prepare();

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

    int count = s.createQuery( "update Mammal set description = description" ).executeUpdate();
    assertEquals( "incorrect update count against 'middle' of joined-subclass hierarchy", 2, count );

    count = s.createQuery( "update Mammal set bodyWeight = 25" ).executeUpdate();
    assertEquals( "incorrect update count against 'middle' of joined-subclass hierarchy", 2, count );
View Full Code Here

    Transaction t = s.beginTransaction();

    int count = s.createQuery( "update Mammal set description = description" ).executeUpdate();
    assertEquals( "incorrect update count against 'middle' of joined-subclass hierarchy", 2, count );

    count = s.createQuery( "update Mammal set bodyWeight = 25" ).executeUpdate();
    assertEquals( "incorrect update count against 'middle' of joined-subclass hierarchy", 2, count );

    if ( ! ( getDialect() instanceof MySQLDialect ) ) {
      // MySQL does not support (even un-correlated) subqueries against the update-mutating table
      count = s.createQuery( "update Mammal set bodyWeight = ( select max(bodyWeight) from Animal )" ).executeUpdate();
View Full Code Here

    count = s.createQuery( "update Mammal set bodyWeight = 25" ).executeUpdate();
    assertEquals( "incorrect update count against 'middle' of joined-subclass hierarchy", 2, count );

    if ( ! ( getDialect() instanceof MySQLDialect ) ) {
      // MySQL does not support (even un-correlated) subqueries against the update-mutating table
      count = s.createQuery( "update Mammal set bodyWeight = ( select max(bodyWeight) from Animal )" ).executeUpdate();
      assertEquals( "incorrect update count against 'middle' of joined-subclass hierarchy", 2, count );
    }

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