Package org.hibernate

Examples of org.hibernate.Transaction.commit()


      HibernateUtil.lock(channel, session);
      group.remove(channel);
      HibernateUtil.updateObject(group, session);

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


      tx = session.beginTransaction();

      HibernateUtil.lock(channel, session);
      items = deleteChannel(channel, groups, session);

      tx.commit();

      // Reset Id's of objects
      channel.setId(-1);
      for (int i = 0; i < items.length; i++) {
        items[i].setId(-1);
View Full Code Here

      tx = session.beginTransaction();

      // Create item object and save to database
      deleteItem(item, session);

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

      // Save item to database
      HibernateUtil.lock(channel, session);
      createItem(item, channel, session);

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

    ProjectGroup projectGroup = (ProjectGroup) session.get( ProjectGroup.class, "project-group-1" );
    if ( projectGroup != null ) {
      session.delete( projectGroup );
    }

    transaction.commit();
    session.close();
  }

  @Test(expected = StaleObjectStateException.class)
  public void concurrentModificationShouldCauseException() throws Exception {
View Full Code Here

    String newRevision = doConcurrentUpdateToNovel();
    assertThat( newRevision ).isNotEqualTo( novel.get_rev() );

    Transaction transaction = session.beginTransaction();
    novel.setDescription( "Description 2" );
    transaction.commit();
  }

  @Test(expected = StaleObjectStateException.class)
  public void mergeAfterConcurrentModificationShouldCauseException() throws Exception {
    Novel novel = createAndPersistNovel();
View Full Code Here

    Novel novel = (Novel) session.get( Novel.class, "novel-1" );
    concurrentlyDeleteNovel();
    novel.setPosition( 2 );

    transaction.commit();
  }

  @Test(expected = StaleObjectStateException.class)
  public void deletionAfterConcurrentModificationShouldCauseException() throws Exception {
    Novel novel = createAndPersistNovel();
View Full Code Here

    doConcurrentUpdateToNovel();

    Transaction transaction = session.beginTransaction();
    session.delete( novel );
    transaction.commit();
  }

  private Novel createAndPersistNovel() {
    Transaction transaction = session.beginTransaction();
View Full Code Here

    Novel novel = createNovel();

    assertThat( novel.get_rev() ).isNull();
    session.persist( novel );
    transaction.commit();
    assertThat( novel.get_rev() ).isNotNull();
    return novel;
  }

  private Novel createNovel() {
View Full Code Here

        Session session = openSession();

        Transaction transaction = session.beginTransaction();
        final Novel novel = (Novel) session.get( Novel.class, "novel-1" );
        novel.setDescription( "Description 2" );
        transaction.commit();

        return novel.get_rev();
      }
    } ).get();
  }
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.