Package org.hibernate

Examples of org.hibernate.Session.saveOrUpdate()


    s.persist( entity );
    s.merge( new TimestampedEntity( "test", "test-2" ) );

    try {
      // control operation...
      s.saveOrUpdate( new TimestampedEntity( "test", "test-3" ) );
      fail( "saveOrUpdate() should fail here" );
    }
    catch( NonUniqueObjectException expected ) {
      // expected behavior
    }
View Full Code Here


    t.commit();
    s.close();
   
    s = openSession();
    t = s.beginTransaction();
    s.saveOrUpdate(cust);
    ship = cust.getShippingAddress();
    cust.setShippingAddress(null);
    s.delete("ShippingAddress", ship);
    s.flush();
    assertNull( s.get( "ShippingAddress", ship.getAddressId() ) );
View Full Code Here

    s.merge( new VersionedEntity( "test", "test-2" ) );
    s = applyNonFlushedChangesToNewSessionCloseOldSession( s );

    try {
      // control operation...
      s.saveOrUpdate( new VersionedEntity( "test", "test-3" ) );
      fail( "saveOrUpdate() should fail here" );
    }
    catch ( NonUniqueObjectException expected ) {
      // expected behavior
    }
View Full Code Here

    s.merge( new TimestampedEntity( "test", "test-2" ) );
    s = applyNonFlushedChangesToNewSessionCloseOldSession( s );

    try {
      // control operation...
      s.saveOrUpdate( new TimestampedEntity( "test", "test-3" ) );
      fail( "saveOrUpdate() should fail here" );
    }
    catch ( NonUniqueObjectException expected ) {
      // expected behavior
    }
View Full Code Here

    clearCounts();

    s = openSession();
    t = s.beginTransaction();
    cv1.getInfos().add( new Info( "cv1 info" ) );
    s.saveOrUpdate( c );
    t.commit();
    s.close();

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

    clearCounts();

    s = openSession();
    t = s.beginTransaction();
    cv1Info.setText( "new cv1 info" );
    s.saveOrUpdate( c );
    t.commit();
    s.close();

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

    session.beginTransaction();

    emp.setInfo( null );

    //save using the new session (this used to work prior to 3.5.x)
    session.saveOrUpdate(emp);

    session.getTransaction().commit();
    session.close();

    session = openSession();
View Full Code Here

    c.setDescription("Grade 5 English");
    uc.setDescription("Second year mathematics");
   
    s = openSession();
    t = s.beginTransaction();
    s.saveOrUpdate(c);
    s.saveOrUpdate(uc);
    t.commit();
    s.close();
   
    s = openSession();
View Full Code Here

    uc.setDescription("Second year mathematics");
   
    s = openSession();
    t = s.beginTransaction();
    s.saveOrUpdate(c);
    s.saveOrUpdate(uc);
    t.commit();
    s.close();
   
    s = openSession();
    t = s.beginTransaction();
View Full Code Here

      session = HibernateContext.getSessionFactory().openSession();
      transaction = session.beginTransaction();

    //  Save user
    //
      session.saveOrUpdate(user);
      transaction.commit();
     
      return user;
    }
    catch (RuntimeException e)
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.