Package org.hibernate

Examples of org.hibernate.Session.clear()


    account.getAddresses().add( anotherAddress );

    session.persist( account );
    transaction.commit();

    session.clear();

    transaction = session.beginTransaction();
    MultiAddressAccount loadedAccount = (MultiAddressAccount) session.get( MultiAddressAccount.class, account.getLogin() );
    assertThat( loadedAccount ).as( "Cannot load persisted object" ).isNotNull();
    assertThat( loadedAccount.getAddresses() ).onProperty( "city" ).contains( "Paris", "Rome" );
View Full Code Here


    Address loadedAddress1 = loadedAccount.getAddresses().get( 0 );
    Address loadedAddress2 = loadedAccount.getAddresses().get( 1 );

    transaction.commit();

    session.clear();

    transaction = session.beginTransaction();
    loadedAddress1.setCountry( "USA" );
    loadedAddress2.setCountry( "Germany" );
View Full Code Here

    loadedAddress2.setCountry( "Germany" );

    session.merge( loadedAccount );
    transaction.commit();

    session.clear();

    transaction = session.beginTransaction();
    MultiAddressAccount secondLoadedAccount = (MultiAddressAccount) session.get( MultiAddressAccount.class, account.getLogin() );
    assertThat( secondLoadedAccount.getAddresses() ).onProperty( "city" ).contains( "Paris", "Rome" );
    assertThat( secondLoadedAccount.getAddresses() ).onProperty( "country" ).contains( "USA", "Germany" );
View Full Code Here

    assertThat( secondLoadedAccount.getAddresses() ).onProperty( "city" ).contains( "Paris", "Rome" );
    assertThat( secondLoadedAccount.getAddresses() ).onProperty( "country" ).contains( "USA", "Germany" );
    session.delete( secondLoadedAccount );
    transaction.commit();

    session.clear();

    transaction = session.beginTransaction();
    assertThat( session.get( MultiAddressAccount.class, account.getLogin() ) ).isNull();
    transaction.commit();
View Full Code Here

    item.setItemName( "Fairway Wood 19°" );
    item.setCount( 25 );
    session.persist( item );

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

    // load and update
    StockItem loadedItem = (StockItem) session.get( StockItem.class, item.getId() );
    assertNotNull( "Cannot load persisted object", loadedItem );
View Full Code Here

    StockItem loadedItem = (StockItem) session.get( StockItem.class, item.getId() );
    assertNotNull( "Cannot load persisted object", loadedItem );
    loadedItem.setCount( 24 );

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

    // delete
    loadedItem = (StockItem) session.get( StockItem.class, item.getId() );
    assertNotNull( "Cannot load persisted object", loadedItem );
View Full Code Here

    loadedItem = (StockItem) session.get( StockItem.class, item.getId() );
    assertNotNull( "Cannot load persisted object", loadedItem );
    session.delete( loadedItem );

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

    assertThat( getOperations() ).containsExactly(
        "getTuple",
        "createTuple",
View Full Code Here

    Account account = new Account();
    account.setLogin( "gunnar" );
    session.persist( account );

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

    // read back
    transaction = session.beginTransaction();
    Account loadedAccount = (Account) session.get( Account.class, account.getLogin() );
    assertThat( loadedAccount ).as( "Cannot load persisted object with nested embeddables which are null" ).isNotNull();
View Full Code Here

    loadedAccount.setHomeAddress( new Address() );
    loadedAccount.getHomeAddress().setCity( "Lima" );
    loadedAccount.getHomeAddress().setType( new AddressType( "primary" ) );

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

    // read back nested embeddable
    transaction = session.beginTransaction();
    loadedAccount = (Account) session.get( Account.class, account.getLogin() );
    assertThat( loadedAccount ).as( "Cannot load persisted object with nested embeddedables" ).isNotNull();
View Full Code Here

    // update
    item.setCount( 24 );

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

    StockItem loadedItem = (StockItem) session.get( StockItem.class, item.getId() );
    assertNotNull( "Cannot load persisted object", loadedItem );
    session.delete( loadedItem );
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.