Package org.hibernate

Examples of org.hibernate.Transaction.commit()


    // when inserting a golf player
    GolfPlayer ben = new GolfPlayer( 1L, "Ben", 0.1 );
    session.persist( ben );

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

    // then expect one (batched) insert with the configured write concern
    verify( mockClient.getCollection( "GolfPlayer" ) ).insert( any( List.class ), eq( WriteConcern.MAJORITY ) );
  }
View Full Code Here


    // when
    session.persist( brian );
    session.persist( cubaLibre );

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

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

    // when updating the golf player
    GolfPlayer ben = new GolfPlayer( 1L, "Ben", 0.2 );
    session.merge( ben );

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

    // then expect one (batched) insert with the configured write concern
    verify( mockClient.getCollection( "GolfPlayer" ) ).update( any( DBObject.class ), any( DBObject.class ), anyBoolean(), anyBoolean(), eq( WriteConcern.MAJORITY ) );
  }
View Full Code Here

    // then
    assertThat( brianLoaded.getName() ).isEqualTo( "Brian" );
    assertThat( brianLoaded.getFavoriteDrink() ).isNotNull();
    assertThat( brianLoaded.getFavoriteDrink().getName() ).isEqualTo( "Cuba Libre" );

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

  @Test
  public void canUseObjectIdAssignedUponInsert() {
View Full Code Here

    // when removing the golf player
    GolfPlayer ben = new GolfPlayer( 1L, "Ben", 0.1 );
    session.delete( ben );

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

    // then expect a call to remove with the configured write concern
    verify( mockClient.getCollection( "GolfPlayer" ) ).remove( any( DBObject.class ), eq( WriteConcern.MAJORITY ) );
  }
View Full Code Here

    Bar goldFishBar = new Bar( "Goldfisch Bar" );

    // when
    session.persist( goldFishBar );

    tx.commit();
    assertThat( goldFishBar.getId() ).isNotNull();
    session.clear();
    tx = session.beginTransaction();

    Bar barLoaded = (Bar) session.load( Bar.class, goldFishBar.getId() );
View Full Code Here

    Transaction transaction = session.beginTransaction();
    final FullTextSession fts = Search.getFullTextSession( session );
    final Insurance insurance = new Insurance();
    insurance.setName( "Macif" );
    fts.persist( insurance );
    transaction.commit();

    fts.clear();

    transaction = fts.beginTransaction();
    final QueryBuilder b = fts.getSearchFactory()
View Full Code Here

    Helicopter helicopter = new Helicopter();
    helicopter.setMake( "Lama" );
    helicopter.setName( "Sergio" );
    session.persist( helicopter );

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

  @Test
  public void canUpdateEntityReturnedByQuery() {
View Full Code Here

    final List<Insurance> resultList = ftQuery.list();
    assertThat( resultList ).hasSize( 1 );
    for ( Object e : resultList ) {
      fts.delete( e );
    }
    transaction.commit();
    fts.close();
  }

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

    Query query = session.createQuery( "from Helicopter h where name = 'Sergio'" );
    Helicopter helicopter = (Helicopter) query.uniqueResult();
    assertThat( helicopter ).isNotNull();
    helicopter.setName( "Leonie" );

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

    query = session.createQuery( "from Helicopter h where name = 'Leonie'" );
    helicopter = (Helicopter) query.uniqueResult();
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.