Package org.hibernate.ogm

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


    session.persist( goldFishBar );

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

    Bar barLoaded = (Bar) session.load( Bar.class, goldFishBar.getId() );

    // then
    assertThat( barLoaded.getName() ).isEqualTo( "Goldfisch Bar" );
View Full Code Here


  }

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

    // given
    MusicGenre classicRock = new MusicGenre( "Classic Rock" );

    Bar goldFishBar = new Bar( "Goldfisch Bar" );
View Full Code Here

public class OneToOneInEntityMappingTest extends OgmTestCase {

  @Test
  public void testBidirectionalManyToOneMapping() 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( goldFishBar );
    session.persist( sharkStation );

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

    // then
    Bar barLoaded = (Bar) session.load( Bar.class, goldFishBar.getId() );

    assertThat( barLoaded.getName() ).isEqualTo( "Goldfisch Bar" );
View Full Code Here

    assertThat( barLoaded.getMusicGenre() ).isNotNull();
    assertThat( barLoaded.getMusicGenre().getName() ).isEqualTo( "Classic Rock" );

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

    MusicGenre genreLoaded = (MusicGenre) session.load( MusicGenre.class, goldFishBar.getMusicGenre().getId() );
    assertThat( genreLoaded.getPlayedIn() ).onProperty( "name" ).containsOnly( "Goldfisch Bar", "Shark Station" );

    tx.commit();
View Full Code Here

    session.persist( wife );

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

    transaction = session.beginTransaction();

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

  }

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

    // given
    Bar goldFishBar = new Bar( "Goldfisch Bar" );
    goldFishBar.getDoorMen().add( new DoorMan( "Bruce" ) );
    goldFishBar.getDoorMen().add( new DoorMan( "Dwain" ) );
View Full Code Here

    // when
    session.persist( goldFishBar );

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

    // then
    Bar barLoaded = (Bar) session.load( Bar.class, goldFishBar.getId() );
    assertThat( barLoaded.getDoorMen() ).onProperty( "name" ).containsOnly( "Bruce", "Dwain" );
View Full Code Here

  }

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

    // given
    Snack nachos = new Snack( "nachos" );
    Snack frozenYogurt = new Snack( "frozen yogurt" );
    Ingredient milk = new Ingredient( "milk" );
View Full Code Here

    session.persist( milk );
    session.persist( salt );

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

    // then
    Snack frozenYogurtLoaded = (Snack) session.load( Snack.class, frozenYogurt.getId() );

    assertThat( frozenYogurtLoaded.getName() ).isEqualTo( "frozen yogurt" );
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.