Package org.hibernate.classic

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


    int initialVersion = entity.getVersion();

    s = openSession();
    t = s.beginTransaction();
    int count = s.createQuery( "update versioned IntegerVersioned set name = name" ).executeUpdate();
    assertEquals( "incorrect exec count", 1, count );
    t.commit();

    t = s.beginTransaction();
    entity = ( IntegerVersioned ) s.load( IntegerVersioned.class, entity.getId() );
View Full Code Here


      catch (InterruptedException ie) {}
    }

    s = openSession();
    t = s.beginTransaction();
    int count = s.createQuery( "update versioned TimestampVersioned set name = name" ).executeUpdate();
    assertEquals( "incorrect exec count", 1, count );
    t.commit();

    t = s.beginTransaction();
    entity = ( TimestampVersioned ) s.load( TimestampVersioned.class, entity.getId() );
View Full Code Here

    String correctName = "Steve";

    t = s.beginTransaction();

    int count = s.createQuery( "update Human set name.first = :correction where id = :id" )
        .setString( "correction", correctName )
        .setLong( "id", human.getId().longValue() )
        .executeUpdate();

    assertEquals( "Incorrect update count", 1, count );
View Full Code Here

    s.refresh( human );

    assertEquals( "Update did not execute properly", correctName, human.getName().getFirst() );

    s.createQuery( "delete Human" ).executeUpdate();
    t.commit();

    s.close();
  }
View Full Code Here

  public void testUpdateOnManyToOne() {
    Session s = openSession();
    Transaction t = s.beginTransaction();

    s.createQuery( "update Animal a set a.mother = null where a.id = 2" ).executeUpdate();
    if ( ! ( getDialect() instanceof MySQLDialect ) ) {
      // MySQL does not support (even un-correlated) subqueries against the update-mutating table
      s.createQuery( "update Animal a set a.mother = (from Animal where id = 1) where a.id = 2" ).executeUpdate();
    }
View Full Code Here

    Transaction t = s.beginTransaction();

    s.createQuery( "update Animal a set a.mother = null where a.id = 2" ).executeUpdate();
    if ( ! ( getDialect() instanceof MySQLDialect ) ) {
      // MySQL does not support (even un-correlated) subqueries against the update-mutating table
      s.createQuery( "update Animal a set a.mother = (from Animal where id = 1) where a.id = 2" ).executeUpdate();
    }

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

    t.commit();

    t = s.beginTransaction();
    try {
      s.createQuery( "update Human set mother.name.initial = :initial" ).setString( "initial", "F" ).executeUpdate();
      fail( "update allowed across implicit join" );
    }
    catch( QueryException e ) {
      log.debug( "TEST (OK) : " + e.getMessage() );
      // expected condition
View Full Code Here

    catch( QueryException e ) {
      log.debug( "TEST (OK) : " + e.getMessage() );
      // expected condition
    }

    s.createQuery( "delete Human where mother is not null" ).executeUpdate();
    s.createQuery( "delete Human" ).executeUpdate();
    t.commit();
    s.close();
  }
View Full Code Here

      log.debug( "TEST (OK) : " + e.getMessage() );
      // expected condition
    }

    s.createQuery( "delete Human where mother is not null" ).executeUpdate();
    s.createQuery( "delete Human" ).executeUpdate();
    t.commit();
    s.close();
  }

  public void testUpdateOnDiscriminatorSubclass() {
View Full Code Here

    data.prepare();

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

    int count = s.createQuery( "update PettingZoo set name = name" ).executeUpdate();
    assertEquals( "Incorrect discrim subclass update count", 1, count );

    t.rollback();
    t = s.beginTransaction();
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.