Package org.hibernate

Examples of org.hibernate.Session.clear()


    grandMother.getGrandChildren().add( luke );
    grandMother.getGrandChildren().add( leia );
    session.persist( grandMother );
    tx.commit();

    session.clear();

    //remove one of the elements
    tx = session.beginTransaction();
    grandMother = (GrandMother) session.get( GrandMother.class, grandMother.getId() );
    grandMother.getGrandChildren().remove( 0 );
View Full Code Here


    //remove one of the elements
    tx = session.beginTransaction();
    grandMother = (GrandMother) session.get( GrandMother.class, grandMother.getId() );
    grandMother.getGrandChildren().remove( 0 );
    tx.commit();
    session.clear();

    //assert removal has been propagated
    tx = session.beginTransaction();
    grandMother = (GrandMother) session.get( GrandMother.class, grandMother.getId() );
    assertThat( grandMother.getGrandChildren() ).onProperty( "name" ).containsExactly( "Leia" );
View Full Code Here

    DistributedRevisionControl bzr = new DistributedRevisionControl();
    bzr.setName( "Bazaar" );
    session.persist( bzr );

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

    transaction = session.beginTransaction();
    DistributedRevisionControl dvcs = (DistributedRevisionControl) session.get( DistributedRevisionControl.class, git.getId() );
    assertThat( dvcs ).isNotNull();
    assertThat( dvcs.getId() ).isEqualTo( 1 );
View Full Code Here

    user2.getNicknames().add( "idrA" );
    user2.getNicknames().add( "day[9]" );
    session.persist( user2 );
    tx.commit();

    session.clear();

    assertThat( getNumberOfAssociations( sessions, AssociationStorageType.IN_ENTITY ) )
        .describedAs( "Element collection contents should be stored within the entity document" )
        .isEqualTo( 2 );
    assertThat( getNumberOfAssociations( sessions, AssociationStorageType.ASSOCIATION_DOCUMENT ) )
View Full Code Here

    assertThat( user.getNicknames() ).as( "Should have 2 nick1" ).hasSize( 2 );
    assertThat( user.getNicknames() ).as( "Should contain nicks" ).contains( "idrA", "day[9]" );
    user.getNicknames().remove( "idrA" );
    tx.commit();

    session.clear();

    tx = session.beginTransaction();
    user = (User) session.get( User.class, user.getId() );
    // TODO do null value
    assertThat( user.getAddresses() ).as( "List should have 2 elements" ).hasSize( 2 );
View Full Code Here

    simon.setName( "Simon" );
    simon.setSalesForce( force );
    force.getSalesGuys().add( simon );
    session.save( simon );
    transaction.commit();
    session.clear();

    transaction = session.beginTransaction();
    force = (SalesForce) session.get( SalesForce.class, force.getId() );
    assertNotNull( force.getSalesGuys() );
    assertEquals( 2, force.getSalesGuys().size() );
View Full Code Here

    simon = (SalesGuy) session.get( SalesGuy.class, simon.getId() );
    // purposely faulty
    // force.getSalesGuys().remove( simon );
    session.delete( simon );
    transaction.commit();
    session.clear();

    transaction = session.beginTransaction();
    force = (SalesForce) session.get( SalesForce.class, force.getId() );
    assertNotNull( force.getSalesGuys() );
    assertEquals( 1, force.getSalesGuys().size() );
View Full Code Here

    simon.setName( "Simon" );
    simon.setSalesForce( force );
    force.getSalesGuys().add( simon );
    session.save( simon );
    transaction.commit();
    session.clear();

    // removing one sales guy, leaving the other in place
    transaction = session.beginTransaction();
    force = (SalesForce) session.get( SalesForce.class, force.getId() );
    assertEquals( 2, force.getSalesGuys().size() );
View Full Code Here

    assertEquals( 2, force.getSalesGuys().size() );
    SalesGuy salesGuy = (SalesGuy) session.get( SalesGuy.class, eric.getId() );
    salesGuy.setSalesForce( null );
    force.getSalesGuys().remove( salesGuy );
    transaction.commit();
    session.clear();

    transaction = session.beginTransaction();
    force = (SalesForce) session.get( SalesForce.class, force.getId() );
    assertEquals( 1, force.getSalesGuys().size() );
    salesGuy = force.getSalesGuys().iterator().next();
View Full Code Here

    Brewery hoeBrewery = new Brewery();
    hoeBrewery.getBeers().add( hoegaarden );
    hoegaarden.setBrewery( hoeBrewery );
    session.persist( hoeBrewery );
    tx.commit();
    session.clear();

    tx = session.beginTransaction();
    hoegaarden = get( session, Beer.class, hoegaarden.getId() );
    assertThat( hoegaarden ).isNotNull();
    assertThat( hoegaarden.getBrewery() ).isNotNull();
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.