Package org.hibernate

Examples of org.hibernate.Transaction.commit()


    entity.setAnEmbeddable( anEmbeddable );

    // when
    session.persist( entity );

    tx.commit();
    session.clear();
    tx = session.beginTransaction();

    EntityWithObjectIdAndEmbeddable loaded = (EntityWithObjectIdAndEmbeddable) session.load( EntityWithObjectIdAndEmbeddable.class, entity.getId() );
View Full Code Here


    assertThat( loaded.getId() ).isEqualTo( entity.getId() );
    assertThat( loaded.getAnEmbeddable().getEmbeddedString() ).isEqualTo( entity.getAnEmbeddable().getEmbeddedString() );
    assertThat( loaded.getAnEmbeddable().getAnotherEmbeddable().getEmbeddedString() ).isEqualTo(
        entity.getAnEmbeddable().getAnotherEmbeddable().getEmbeddedString() );

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

  @Override
  protected Class<?>[] getAnnotatedClasses() {
View Full Code Here

    hypothesis.setId( "8" );
    hypothesis.setPosition( 8 );
    hypothesis.setDescription( "100\nscientiae" );
    session.persist( hypothesis );

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

  @AfterClass
View Full Code Here

    session.delete( new Hypothesis( "5" ) );
    session.delete( new Hypothesis( "6" ) );
    session.delete( new Hypothesis( "7" ) );
    session.delete( new Hypothesis( "8" ) );

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

  @Before
View Full Code Here

    hibernateOGM.setId( "projectID" );
    hibernateOGM.setName( "HibernateOGM" );
    hibernateOGM.setModules( modules );

    session.persist( hibernateOGM );
    transaction.commit();

    this.addExtraColumn();
    AssociationKeyMetadata metadata = new AssociationKeyMetadata.Builder()
        .table( "Project_Module" )
        .columnNames( new String[] { "Project_id" } )
View Full Code Here

    Transaction transaction = session.beginTransaction();

    // when getting a golf player
    session.get( GolfPlayer.class, 1L );

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

    // then expect a findOne() call with the configured read preference
    verify( mockClient.getCollection( "GolfPlayer" ) ).findOne( any( DBObject.class ), any( DBObject.class ), eq( ReadPreference.secondaryPreferred() ) );
  }
View Full Code Here

    // when getting the golf player
    GolfPlayer ben = (GolfPlayer) session.get( GolfPlayer.class, 1L );
    List<GolfCourse> playedCourses = ben.getPlayedCourses();
    assertThat( playedCourses ).onProperty( "id" ).containsExactly( 1L );

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

    // then expect a findOne() call for the entity and the embedded association with the configured read preference
    verify( mockClient.getCollection( "GolfPlayer" ) ).findOne( any( DBObject.class ), any( DBObject.class ), eq( ReadPreference.secondaryPreferred() ) );
  }
View Full Code Here

    // when getting the golf player
    GolfPlayer ben = (GolfPlayer) session.get( GolfPlayer.class, 1L );
    List<GolfCourse> playedCourses = ben.getPlayedCourses();
    assertThat( playedCourses ).onProperty( "id" ).containsExactly( 1L );

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

    // then expect a findOne() call for the entity and one for the association  with the configured read preference
    verify( mockClient.getCollection( "GolfPlayer" ) ).findOne( any( DBObject.class ), any( DBObject.class ), eq( ReadPreference.secondaryPreferred() ) );
    verify( mockClient.getCollection( "Associations" ) ).findOne( any( DBObject.class ), any( DBObject.class ), eq( ReadPreference.primaryPreferred() ) );
View Full Code Here

    BarKeeper brian = new BarKeeper( new ObjectId(), "Brian" );

    // when
    session.persist( brian );

    tx.commit();
    session.clear();
    tx = session.beginTransaction();

    BarKeeper brianLoaded = (BarKeeper) session.load( BarKeeper.class, brian.getId() );
View Full Code Here

    // then
    assertThat( brianLoaded.getId() ).isEqualTo( brian.getId() );
    assertThat( brianLoaded.getName() ).isEqualTo( "Brian" );

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

  @Test
  public void canUseManuallyAssignedObjectIdInAssociation() {
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.