Package org.hibernate

Examples of org.hibernate.Session.beginTransaction()


    // given an empty database
    MockMongoClient mockClient = mockClient().build();
    setupSessionFactory( new MongoDBDatastoreProvider( mockClient.getClient() ) );

    final Session session = sessions.openSession();
    Transaction transaction = session.beginTransaction();

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

    transaction.commit();
View Full Code Here


        .build();

    setupSessionFactory( new MongoDBDatastoreProvider( mockClient.getClient() ) );

    Session session = sessions.openSession();
    Transaction transaction = session.beginTransaction();

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

        .build();

    setupSessionFactory( new MongoDBDatastoreProvider( mockClient.getClient() ), AssociationStorageType.ASSOCIATION_DOCUMENT );

    Session session = sessions.openSession();
    Transaction transaction = session.beginTransaction();

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

    // given an empty database
    MockMongoClient mockClient = mockClient().build();
    setupSessionFactory( new MongoDBDatastoreProvider( mockClient.getClient() ) );

    final Session session = sessions.openSession();
    Transaction transaction = session.beginTransaction();

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

        .insert( "GolfPlayer", getPlayer() )
        .build();
    setupSessionFactory( new MongoDBDatastoreProvider( mockClient.getClient() ) );

    final Session session = sessions.openSession();
    Transaction transaction = session.beginTransaction();

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

        .build();

    setupSessionFactory( new MongoDBDatastoreProvider( mockClient.getClient() ) );

    final Session session = sessions.openSession();
    Transaction transaction = session.beginTransaction();

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

        .build();

    setupSessionFactory( new MongoDBDatastoreProvider( mockClient.getClient() ) );

    Session session = sessions.openSession();
    Transaction transaction = session.beginTransaction();

    // when associating the golf course to the player
    GolfPlayer ben = new GolfPlayer( 1L, "Ben", 0.1, new GolfCourse( 1L, "Bepple Peach" ) );
    session.merge( ben );
View Full Code Here

    // given an empty database
    MockMongoClient mockClient = mockClient().build();
    setupSessionFactory( new MongoDBDatastoreProvider( mockClient.getClient() ), AssociationStorageType.ASSOCIATION_DOCUMENT );

    Session session = sessions.openSession();
    Transaction transaction = session.beginTransaction();

    // when inserting a player with an associated course
    GolfPlayer ben = new GolfPlayer( 1L, "Ben", 0.1, new GolfCourse( 1L, "Bepple Peach" ) );
    session.persist( ben );
View Full Code Here

          .writeConcern( WriteConcernType.ACKNOWLEDGED );

    sessions = configuration.buildSessionFactory();

    Session session = sessions.openSession();
    Transaction transaction = session.beginTransaction();

    // when inserting a player with an associated course
    GolfPlayer ben = new GolfPlayer( 1L, "Ben", 0.1, new GolfCourse( 1L, "Bepple Peach" ) );
    session.persist( ben );
View Full Code Here

        .build();

    setupSessionFactory( new MongoDBDatastoreProvider( mockClient.getClient() ) );

    Session session = sessions.openSession();
    Transaction transaction = session.beginTransaction();

    // when merging the player with two associated courses
    GolfPlayer ben = new GolfPlayer( 1L, "Ben", 0.1, new GolfCourse( 1L, "Bepple Peach" ), new GolfCourse( 2L, "Ant Sandrews" ) );
    session.merge( ben );
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.