Package org.hibernate.ogm

Examples of org.hibernate.ogm.OgmSession.beginTransaction()


    // when
    session.persist( entity );

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

    EntityWithObjectIdAndEmbeddable loaded = (EntityWithObjectIdAndEmbeddable) session.load( EntityWithObjectIdAndEmbeddable.class, entity.getId() );

    // then
    assertThat( loaded.getId() ).isEqualTo( entity.getId() );
View Full Code Here


public class TableGeneratorTest extends OgmTestCase {

  @Test
  public void canUseSpecificValueColumNames() {
    OgmSession session = openSession();
    Transaction tx = session.beginTransaction();

    // given
    PianoPlayer ken = new PianoPlayer( "Ken Gold" );
    GuitarPlayer buck = new GuitarPlayer( "Buck Cherry" );
    // when
View Full Code Here

    session.persist( ken );
    session.persist( buck );

    tx.commit();
    session.clear();
    tx = session.beginTransaction();
    ken = (PianoPlayer) session.load( PianoPlayer.class, ken.getId() );
    buck = (GuitarPlayer) session.load( GuitarPlayer.class, buck.getId() );

    // then
    assertThat( ken.getId() ).isEqualTo( 1L );
View Full Code Here

public class OneToOneCollectionMappingTest extends OgmTestCase {

  @Test
  public void testAssociationStorageSettingIsIgnoredForBidirectionalManyToOneMapping() throws Exception {
    OgmSession session = openSession();
    Transaction transaction = session.beginTransaction();

    // Given, When
    Husband husband = new Husband( "alex" );
    husband.setName( "Alex" );
    session.persist( husband );
View Full Code Here

    session.persist( wife );

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

    transaction = session.beginTransaction();

    // Then
    assertDbObject(
        session.getSessionFactory(),
        // collection
View Full Code Here

public class ObjectIdTest extends OgmTestCase {

  @Test
  public void canUseManuallyAssignedObjectId() {
    OgmSession session = openSession();
    Transaction tx = session.beginTransaction();

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

    // when
View Full Code Here

    // when
    session.persist( brian );

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

    BarKeeper brianLoaded = (BarKeeper) session.load( BarKeeper.class, brian.getId() );

    // then
    assertThat( brianLoaded.getId() ).isEqualTo( brian.getId() );
View Full Code Here

  }

  @Test
  public void canUseManuallyAssignedObjectIdInAssociation() {
    OgmSession session = openSession();
    Transaction tx = session.beginTransaction();

    // given
    BarKeeper brian = new BarKeeper( new ObjectId(), "Brian" );
    Drink cubaLibre = new Drink( new ObjectId(), "Cuba Libre" );
    brian.setFavoriteDrink( cubaLibre );
View Full Code Here

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

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

    BarKeeper brianLoaded = (BarKeeper) session.load( BarKeeper.class, brian.getId() );

    // then
    assertThat( brianLoaded.getName() ).isEqualTo( "Brian" );
View Full Code Here

  }

  @Test
  public void canUseObjectIdAssignedUponInsert() {
    OgmSession session = openSession();
    Transaction tx = session.beginTransaction();

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

    // when
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.