Package org.hibernate

Examples of org.hibernate.Session.saveOrUpdate()


    SimpleJtaTransactionManagerImpl.getInstance().begin();
    Session s = openSession();
    Node root = new Node( "root" );
    Node child = new Node( "child" );
    root.addChild( child );
    s.saveOrUpdate( root );
    s = applyNonFlushedChangesToNewSessionCloseOldSession( s );
    root = ( Node ) getOldToNewEntityRefMap().get( root );
    child = ( Node ) getOldToNewEntityRefMap().get( child );
    SimpleJtaTransactionManagerImpl.getInstance().commit();
View Full Code Here


    root.addChild( secondChild );

    SimpleJtaTransactionManagerImpl.getInstance().begin();
    s = openSession();
    s.saveOrUpdate( root );
    s = applyNonFlushedChangesToNewSessionCloseOldSession( s );
    SimpleJtaTransactionManagerImpl.getInstance().commit();

    assertInsertCount( 1 );
    assertUpdateCount( 2 );
View Full Code Here

    SimpleJtaTransactionManagerImpl.getInstance().begin();
    Session s = openSession();
    NumberedNode root = new NumberedNode( "root" );
    NumberedNode child = new NumberedNode( "child" );
    root.addChild( child );
    s.saveOrUpdate( root );
    s = applyNonFlushedChangesToNewSessionCloseOldSession( s );
    root = ( NumberedNode ) getOldToNewEntityRefMap().get( root );
    child = ( NumberedNode ) getOldToNewEntityRefMap().get( child );
    SimpleJtaTransactionManagerImpl.getInstance().commit();
View Full Code Here

    root.addChild( secondChild );

    SimpleJtaTransactionManagerImpl.getInstance().begin();
    s = openSession();
    s.saveOrUpdate( root );
    s = applyNonFlushedChangesToNewSessionCloseOldSession( s );
    SimpleJtaTransactionManagerImpl.getInstance().commit();

    assertInsertCount( 1 );
    assertUpdateCount( 2 );
View Full Code Here

    NumberedNode root = new NumberedNode( "root" );
    NumberedNode child = new NumberedNode( "child" );
    NumberedNode grandchild = new NumberedNode( "grandchild" );
    root.addChild( child );
    child.addChild( grandchild );
    s.saveOrUpdate( root );
    tx.commit();
    s.close();

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

    NumberedNode grandchild2 = new NumberedNode( "grandchild2" );
    child.addChild( grandchild2 );

    s = openSession();
    tx = s.beginTransaction();
    s.saveOrUpdate( root );
    tx.commit();
    s.close();

    assertInsertCount( 1 );
    assertUpdateCount( instrumented ? 1 : 3 );
View Full Code Here

  public void testSaveOrUpdateManaged() throws Exception {
    SimpleJtaTransactionManagerImpl.getInstance().begin();
    Session s = openSession();
    NumberedNode root = new NumberedNode( "root" );
    s.saveOrUpdate( root );
    s = applyNonFlushedChangesToNewSessionCloseOldSession( s );
    root = ( NumberedNode ) getOldToNewEntityRefMap().get( root );
    SimpleJtaTransactionManagerImpl.getInstance().commit();

    SimpleJtaTransactionManagerImpl.getInstance().begin();
View Full Code Here

    child2.addChild( grandchild3 );
    root.addChild( child2 );

    s = openSession();
    tx = s.beginTransaction();
    s.saveOrUpdate( root );
    tx.commit();
    s.close();

    assertInsertCount( 2 );
    assertUpdateCount( instrumented ? 0 : 4 );
View Full Code Here

    SimpleJtaTransactionManagerImpl.getInstance().begin();
    s = openSession();
    root = ( NumberedNode ) s.get( NumberedNode.class, root.getId() );
    NumberedNode child = new NumberedNode( "child" );
    root.addChild( child );
    s.saveOrUpdate( root );
    s = applyNonFlushedChangesToNewSessionCloseOldSession( s );
    root = ( NumberedNode ) getOldToNewEntityRefMap().get( root );
    assertNull( getOldToNewEntityRefMap().get( child ) );
    s.flush();
    s = applyNonFlushedChangesToNewSessionCloseOldSession( s );
View Full Code Here

    Session s = openSession();
    Transaction tx = s.beginTransaction();
    Node root = new Node( "root" );
    Node child = new Node( "child" );
    root.addChild( child );
    s.saveOrUpdate( root );
    tx.commit();
    s.close();

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