Package org.hibernate

Examples of org.hibernate.Session.merge()


    // node is now detached, but we have made no changes.  so attempt to merge it
    // into this new session; this should cause no updates...
    s = openSession();
    s.beginTransaction();
    node = ( Node ) s.merge( node );
    s.getTransaction().commit();
    s.close();

    assertUpdateCount( 0 );
    assertInsertCount( 0 );
View Full Code Here


    // as a control measure, now update the node while it is detached and
    // make sure we get an update as a result...
    node.setDescription( "new description" );
    s = openSession();
    s.beginTransaction();
    node = ( Node ) s.merge( node );
    s.getTransaction().commit();
    s.close();
    assertUpdateCount( 1 );
    assertInsertCount( 0 );
    ///////////////////////////////////////////////////////////////////////
View Full Code Here

    // parent is now detached, but we have made no changes.  so attempt to merge it
    // into this new session; this should cause no updates...
    s = openSession();
    s.beginTransaction();
    parent = ( Node ) s.merge( parent );
    s.getTransaction().commit();
    s.close();

    assertUpdateCount( 0 );
    assertInsertCount( 0 );
View Full Code Here

    // make sure we get an update as a result...
    ( ( Node ) parent.getChildren().iterator().next() ).setDescription( "child's new description" );
    parent.addChild( new Node( "second child" ) );
    s = openSession();
    s.beginTransaction();
    parent = ( Node ) s.merge( parent );
    s.getTransaction().commit();
    s.close();
    assertUpdateCount( 1 );
    assertInsertCount( 1 );
    ///////////////////////////////////////////////////////////////////////
View Full Code Here

    // entity is now detached, but we have made no changes.  so attempt to merge it
    // into this new session; this should cause no updates...
    s = openSession();
    s.beginTransaction();
    VersionedEntity mergedEntity = ( VersionedEntity ) s.merge( entity );
    s.getTransaction().commit();
    s.close();

    assertUpdateCount( 0 );
    assertInsertCount( 0 );
View Full Code Here

    document.getOwner().setPersonalInfo( new PersonalInfo( addr ) );

    // step4 we merge the document
    session = openSession();
    session.beginTransaction();
    session.merge( document );
    session.getTransaction().commit();
    session.close();

    // step5, final test
    session = openSession();
View Full Code Here

    // as a control measure, now update the node while it is detached and
    // make sure we get an update as a result...
    entity.setName( "new name" );
    s = openSession();
    s.beginTransaction();
    entity = ( VersionedEntity ) s.merge( entity );
    s.getTransaction().commit();
    s.close();
    assertUpdateCount( 1 );
    assertInsertCount( 0 );
    ///////////////////////////////////////////////////////////////////////
View Full Code Here

    // parent is now detached, but we have made no changes.  so attempt to merge it
    // into this new session; this should cause no updates...
    s = openSession();
    s.beginTransaction();
    VersionedEntity mergedParent = ( VersionedEntity ) s.merge( parent );
    s.getTransaction().commit();
    s.close();

    assertUpdateCount( 0 );
    assertInsertCount( 0 );
View Full Code Here

    // now try to reattch it
    SimpleJtaTransactionManagerImpl.getInstance().begin();
    s = openSession();
    try {
      s.merge( entity );
      s = applyNonFlushedChangesToNewSessionCloseOldSession( s );
      entity = ( VersionedEntity ) getOldToNewEntityRefMap().get( entity );
      SimpleJtaTransactionManagerImpl.getInstance().commit();
      fail( "was expecting staleness error" );
    }
View Full Code Here

    clearCounts();

    p.getDetails().setSomePersonalDetail( p.getDetails().getSomePersonalDetail() + " and big hands too" );
    SimpleJtaTransactionManagerImpl.getInstance().begin();
    s = openSession();
    p = ( Person ) s.merge( p );
    s = applyNonFlushedChangesToNewSessionCloseOldSession( s );
    p = ( Person ) getOldToNewEntityRefMap().get( p );
    SimpleJtaTransactionManagerImpl.getInstance().commit();

    assertInsertCount( 0 );
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.