Package org.hibernate

Examples of org.hibernate.Session.clear()


    hoeBrewery.getBeers().add( citron );
    citron.setBrewery( hoeBrewery );
    session.delete( hoegaarden );
    tx.commit();

    session.clear();

    tx = session.beginTransaction();
    citron = get( session, Beer.class, citron.getId() );
    assertThat( citron.getBrewery().getBeers() )
      .hasSize( 1 )
View Full Code Here


    Transaction transaction = session.beginTransaction();
    session.persist( portia );
    session.persist( athanasia );
    session.persist( imperatrix );
    transaction.commit();
    session.clear();
    session.close();
  }

  @After
  public void tearDown() {
View Full Code Here

    Transaction tx = session.beginTransaction();
    delete( session, portia );
    delete( session, athanasia );
    delete( session, imperatrix );
    tx.commit();
    session.clear();
    session.close();
  }

  private void delete(Session session, OscarWildePoem poem) {
    Object entity = session.get( OscarWildePoem.class, poem.getId() );
View Full Code Here

    simon.setSalesForce( force );
    force.getSalesGuys().add( simon );
    session.save( simon );

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

    transaction = session.beginTransaction();

    // The classic API allows to delete transient instances;
    // Intentionally not deleting the referencing sales guys
View Full Code Here

          .uniqueResult();
      assertAreEquals( uniqueResult, athanasia );
      transaction.commit();
    }
    finally {
      session.clear();
      session.close();
    }
  }

  @Test
View Full Code Here

    session.persist( owner );
    tx.commit();

    assertThat( getNumberOfEntities( sessions ) ).isEqualTo( 2 );
    assertThat( getNumberOfAssociations( sessions ) ).isEqualTo( expectedAssociationNumber() );
    session.clear();

    // read from inverse side
    tx = session.beginTransaction();
    soge = get( session, BankAccount.class, soge.getId() );
    assertThat( soge.getOwners() ).hasSize( 1 );
View Full Code Here

    soge = get( session, BankAccount.class, soge.getId() );
    assertThat( soge.getOwners() ).hasSize( 1 );
    assertThat( soge.getOwners() ).onProperty( "id" ).contains( owner.getId() );
    tx.commit();

    session.clear();

    // read from non-inverse side and update data
    tx = session.beginTransaction();
    owner = get( session, AccountOwner.class, owner.getId() );
    assertThat( owner.getBankAccounts() ).hasSize( 1 );
View Full Code Here

    session.delete( soge );
    tx.commit();

    assertThat( getNumberOfEntities( sessions ) ).isEqualTo( 2 );
    assertThat( getNumberOfAssociations( sessions ) ).isEqualTo( expectedAssociationNumber() );
    session.clear();

    // delete data
    tx = session.beginTransaction();
    owner = get( session, AccountOwner.class, owner.getId() );
    assertThat( owner.getBankAccounts() ).hasSize( 1 );
View Full Code Here

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

    session.clear();

    if ( getCurrentDialectType().isDocumentStore() ) {
      assertThat( getNumberOfAssociations( sessions, AssociationStorageType.IN_ENTITY ) )
          .describedAs( "Map contents and element collections should be stored within the entity document" )
          .isEqualTo( 3 );
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( "Map should have 2 elements" ).hasSize( 2 );
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.