Package org.hibernate

Examples of org.hibernate.Transaction.commit()


        Session session = openSession();

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

        return novel.get_rev();
      }
    } ).get();
  }
View Full Code Here


    String newRevision = doConcurrentUpdateToAnimal();
    assertThat( newRevision ).isNotEqualTo( animal.getRevision() );

    Transaction transaction = session.beginTransaction();
    animal.setName( "Xavier" );
    transaction.commit();
  }

  @Test
  public void canUpdateObjectPropertyAfterUpdateOfAssociationStoredInEntity() {
    Animal animal1 = createAndPersistAnimal();
View Full Code Here

    Transaction transaction = session.beginTransaction();

    zoo.getAnimals().add( animal2 );
    zoo.setName( "Hilwelma" );

    transaction.commit();

    transaction = session.beginTransaction();

    zoo = (Zoo) session.get( Zoo.class, "zoo-1" );
    assertThat( zoo.getName() ).isEqualTo( "Hilwelma" );
View Full Code Here

    zoo = (Zoo) session.get( Zoo.class, "zoo-1" );
    assertThat( zoo.getName() ).isEqualTo( "Hilwelma" );
    assertThat( zoo.getAnimals() ).onProperty( "name" ).containsOnly( "Bruno", "Berta" );

    transaction.commit();
  }

  @Test
  public void canUpdateEntityAfterUpdateOfAssociationStoredInEntityOnInverseSide() {
    Project project = createAndPersistProjectWithProjectGroup();
View Full Code Here

    Transaction transaction = session.beginTransaction();

    project.getProjectGroup().setName( "Fancy projects" );

    transaction.commit();

    transaction = session.beginTransaction();

    ProjectGroup projectGroup = (ProjectGroup) session.get( ProjectGroup.class, "project-group-1" );
    assertThat( projectGroup.getName() ).isEqualTo( "Fancy projects" );
View Full Code Here

    ProjectGroup projectGroup = (ProjectGroup) session.get( ProjectGroup.class, "project-group-1" );
    assertThat( projectGroup.getName() ).isEqualTo( "Fancy projects" );
    assertThat( projectGroup.getProjects() ).onProperty( "name" ).containsOnly( "Validator" );

    transaction.commit();
  }

  @Test
  public void canUpdateEntityAfterRemovalOfAssociationStoredInEntityOnInverseSide() {
    Project project = createAndPersistProjectWithProjectGroup();
View Full Code Here

    Transaction transaction = session.beginTransaction();

    projectGroup.getProjects().remove( project );
    project.setProjectGroup( null );

    transaction.commit();

    transaction = session.beginTransaction();

    projectGroup.setName( "Fancy projects" );
View Full Code Here

    transaction = session.beginTransaction();

    projectGroup.setName( "Fancy projects" );

    transaction.commit();

    transaction = session.beginTransaction();

    projectGroup = (ProjectGroup) session.get( ProjectGroup.class, "project-group-1" );
    assertThat( projectGroup.getName() ).isEqualTo( "Fancy projects" );
View Full Code Here

    projectGroup = (ProjectGroup) session.get( ProjectGroup.class, "project-group-1" );
    assertThat( projectGroup.getName() ).isEqualTo( "Fancy projects" );
    assertThat( projectGroup.getProjects() ).isEmpty();

    transaction.commit();
  }

  @Test
  public void canUpdateEntityOnInverseSideOfManyToManyAssocationAfterUpdateToAssociation() throws Exception {
    // given
View Full Code Here

    // when
    Transaction transaction = session.beginTransaction();
    User bob = search.getUsers().iterator().next();
    bob.getProjects().add( ogm );
    ogm.getUsers().add( bob );
    transaction.commit();

    transaction = session.beginTransaction();
    bob.setName( "Alice" );
    transaction.commit();
    session.clear();
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.