Package org.hibernate

Examples of org.hibernate.Session.merge()


     * {@inheritDoc}
     */
    @SuppressWarnings("unchecked")
    public T save(T object) {
        Session sess = getSession();
        return (T) sess.merge(object);
    }

    /**
     * {@inheritDoc}
     */
 
View Full Code Here


                             AccountDO accountsDO = (AccountDO)session.load(AccountDO.class, 2);
                           tx.commit();
                           //accountsDO.setAccountId(2);
                           accountsDO.setName("gfeabcaaaaad");
                           accountsDO.setLoginName("gfeaaaaaaa");
                           session.merge(accountsDO);
                         
                           SlipDO slip  = (SlipDO)objectDAO.load(SlipDO.class,new Integer(21070));
                          
                         }
                         catch (Exception ex) {
View Full Code Here

      // The new membership is transient (it has a null surrogate ID), so
      // Hibernate assumes that it should be added to the collection.
      // Inserts are done before deletes, so a ConstraintViolationException
      // will be thrown on the insert because the unique constraint on the
      // user and group IDs in the join table is violated. See HHH-2801.
      s.merge( getUser() );
      s.getTransaction().commit();
      fail( "should have failed because inserts are before deletes");
    }
    catch( ConstraintViolationException ex ) {
      // expected
View Full Code Here

      // The new membership is transient (it has a null surrogate ID), so
      // Hibernate assumes that it should be added to the collection.
      // Inserts are done before deletes, so a ConstraintViolationException
      // will be thrown on the insert because the unique constraint on the
      // user and group IDs in the join table is violated. See HHH-2801.
      s.merge( getUser() );
      s.getTransaction().commit();
      fail( "should have failed because inserts are before deletes");
    }
    catch( ConstraintViolationException ex ) {
      // expected
View Full Code Here

      // The new membership is transient (it has a null surrogate ID), so
      // Hibernate assumes that it should be added to the collection.
      // Inserts are done before deletes, so a ConstraintViolationException
      // will be thrown on the insert because the unique constraint on the
      // user and group IDs in the join table is violated. See HHH-2801.
      s.merge( getUser() );
      s.getTransaction().commit();
      fail( "should have failed because inserts are before deletes");
    }
    catch( ConstraintViolationException ex ) {
      // expected
View Full Code Here

    tx.commit();
    s.close();

    s = openSession();
    tx = s.beginTransaction();
    team = (SoccerTeam)s.merge(team);
    int count = ( (Long) s.createQuery( "select count(*) from Player" ).iterate().next() ).intValue();
    assertEquals("expected count of 3 but got = " + count, count, 3);

    // clear references to players, this should orphan the players which should
    // in turn trigger orphanRemoval logic.
View Full Code Here

    PurchaseRecord persistent = (PurchaseRecord) s.get(PurchaseRecord.class, generatedId);
   
    // show that the timestamp hasn't changed
    assertEquals( df.format(timestamp1), df.format(persistent.getTimestamp()) );
   
    s.merge(detached);
   
    t.commit();
    s.close();

    // show that the persistent object was changed only after the session flush
View Full Code Here

    s = openSession();
    t = s.beginTransaction();
    DataPoint dpManaged = ( DataPoint ) s.get( DataPoint.class, new Long( dp.getId() ) );
    s.setReadOnly( dpManaged, true );
    DataPoint dpMerged = ( DataPoint ) s.merge( dp );
    assertSame( dpManaged, dpMerged );
    t.commit();
    s.close();

    assertUpdateCount( 0 );
View Full Code Here

    membership = createMembership( "membership" );
    addMembership( user, group, membership );

    Session s = openSession();
    s.beginTransaction();
    s.merge( user );
    s.getTransaction().commit();
    s.close();

    s = openSession();
    s.beginTransaction();
View Full Code Here

    group.setMemberships( new HashSet() );
    addMembership( user, group, membership );

    Session s = openSession();
    s.beginTransaction();
    s.merge( user );
    s.getTransaction().commit();
    s.close();

    s = openSession();
    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.