Package org.hibernate

Examples of org.hibernate.Session.merge()


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

    // merging back the previously loaded version will cause an exception
    try {
      entity = (Planet) session.merge( entity );
    }
    finally {
      commitTransactionAndPropagateExceptions( session, transaction );
    }
  }
View Full Code Here


    session.clear();

    transaction = session.beginTransaction();
    loadedAddress.setCountry( "USA" );
    session.merge( loadedAccount );
    transaction.commit();

    session.clear();

    transaction = session.beginTransaction();
View Full Code Here

    transaction = session.beginTransaction();
    loadedAddress1.setCountry( "USA" );
    loadedAddress2.setCountry( "Germany" );

    session.merge( loadedAccount );
    transaction.commit();

    session.clear();

    transaction = session.beginTransaction();
View Full Code Here

    Session session = null;

    try {
      sessionFactory = HibernateSessionFactory.getInstance();
      session = sessionFactory.openSession();
      Object mergedObject = session.merge(objToSave);
      return mergedObject;

    } catch (Exception a_th) {
      throw new RuntimeException(a_th);
    } finally {
View Full Code Here

    root.addChild( secondChild );

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

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

    root.addChild( secondChild );

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

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

    Session session = getSession();
    if (EntityStatus.TRANSIENT == getStatus(model)) {
      session.persist(model);
      return model;
    } else {
      return (T) session.merge(model);
    }
  }
 
  public <T> void delete(T model) {
    Session session = getSession();
View Full Code Here

   }

   public Object save(Object obj) throws Exception
   {
      Session session = openSession();
      session.merge(obj);
      session.flush();
      return obj;
   }

   public Object remove(Object obj) throws Exception
View Full Code Here

    Session s = factory.openSession();
    Transaction tx=null;
    try {
      tx = s.beginTransaction();

      s.merge(user);

      tx.commit();
    }
    catch (Exception e) {
      if (tx!=null) tx.rollback();
View Full Code Here

    a.setState( "WAYTOOLONG" );
    s = openSession();
    tx = s.beginTransaction();
    try {
      s.merge( a );
      tx.commit();
      fail( "bean should have been validated" );
    }
    catch (InvalidStateException e) {
      //success
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.