Package org.hibernate

Examples of org.hibernate.Session.clear()


    session.persist( home );
    session.persist( work );
    session.persist( user );
    tx.commit();
    session.clear();

    // Load user and remove one address
    tx = session.beginTransaction();

    user = (User) session.get( User.class, user.getId() );
View Full Code Here


    user = (User) session.get( User.class, user.getId() );
    user.getAddresses().remove( "work" );

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

    // assert
    tx = session.beginTransaction();

    user = (User) session.get( User.class, user.getId() );
View Full Code Here

    cavalier.setName( "Caroline" );
    cavalier.setHorse( horse );
    session.persist( horse );
    session.persist( cavalier );
    transaction.commit();
    session.clear();

    transaction = session.beginTransaction();
    cavalier = (Cavalier) session.get( Cavalier.class, cavalier.getId() );
    horse = cavalier.getHorse();
    session.delete( cavalier );
View Full Code Here

    Wheel wheel = new Wheel();
    wheel.setVehicule( vehicule );
    session.persist( vehicule );
    session.persist( wheel );
    transaction.commit();
    session.clear();

    transaction = session.beginTransaction();
    wheel = (Wheel) session.get( Wheel.class, wheel.getId() );
    vehicule = wheel.getVehicule();
    session.delete( wheel );
View Full Code Here

    husband.setWife( wife );
    wife.setHusband( husband );
    session.persist( husband );
    session.persist( wife );
    transaction.commit();
    session.clear();

    transaction = session.beginTransaction();
    husband = (Husband) session.get( Husband.class, husband.getId() );
    assertNotNull( husband );
    assertNotNull( husband.getWife() );
View Full Code Here

    transaction = session.beginTransaction();
    husband = (Husband) session.get( Husband.class, husband.getId() );
    assertNotNull( husband );
    assertNotNull( husband.getWife() );
    session.clear();
    wife = (Wife) session.get( Wife.class, wife.getId() );
    assertNotNull( wife );
    husband = wife.getHusband();
    assertNotNull( husband );
    Wife bea2 = new Wife( "still_bea" );
View Full Code Here

    bea2.setName( "Still Bea" );
    husband.setWife( bea2 );
    wife.setHusband( null );
    bea2.setHusband( husband );
    transaction.commit();
    session.clear();

    transaction = session.beginTransaction();
    husband = (Husband) session.get( Husband.class, husband.getId() );
    assertNotNull( husband );
    assertNotNull( husband.getWife() );
View Full Code Here

    transaction = session.beginTransaction();
    husband = (Husband) session.get( Husband.class, husband.getId() );
    assertNotNull( husband );
    assertNotNull( husband.getWife() );
    session.clear();
    wife = (Wife) session.get( Wife.class, wife.getId() );
    assertNotNull( wife );
    assertNull( wife.getHusband() );
    session.delete( wife );
    bea2 = (Wife) session.get( Wife.class, bea2.getId() );
View Full Code Here

    // persist object with association
    Director bob = new Director( "bob", "Bob", playersChampionship );
    session.persist( bob );

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

    // assert and un-set the association
    transaction = session.beginTransaction();

    Director loadedParticipant = (Director) session.get( Director.class, "bob" );
View Full Code Here

    Director loadedParticipant = (Director) session.get( Director.class, "bob" );
    assertThat( bob.getDirectedTournament().getName() ).isEqualTo( "Player's Championship" );
    bob.setDirectedTournament( null );

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

    // association should have been removed
    transaction = session.beginTransaction();

    loadedParticipant = (Director) session.get( Director.class, "bob" );
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.