Package org.hibernate

Examples of org.hibernate.Session.clear()


      Session session = openSession();
      Transaction transaction = session.beginTransaction();
      IndexedNews news = new IndexedNews( new NewsID( "title", "author" ), "content" );
      session.persist( news );
      transaction.commit();
      session.clear();
      session.close();
    }
    {
      purgeAll( IndexedNews.class );
      startAndWaitMassIndexing( IndexedNews.class );
View Full Code Here


    sh.setName( "Batman" );
    sh.setSpecialPower( "Technology and samurai techniques" );
    session.persist( sh );
    transaction.commit();

    session.clear();

    transaction = session.beginTransaction();
    Hero lh = (Hero) session.get( Hero.class, h.getName() );
    assertNotNull( lh );
    assertEquals( h.getName(), lh.getName() );
View Full Code Here

      assertThat( list ).hasSize( 1 );
      assertThat( list.get( 0 ).getContent() ).isEqualTo( "content" );
      assertThat( list.get( 0 ).getNewsId().getTitle() ).isEqualTo( "title" );
      assertThat( list.get( 0 ).getNewsId().getAuthor() ).isEqualTo( "author" );
      transaction.commit();
      session.clear();
      session.close();
    }
  }

  @AfterClass
View Full Code Here

    transaction.commit();

    assertThat( getNumberOfEntities( sessions ) ).isEqualTo( 3 );
    assertThat( getNumberOfAssociations( sessions ) ).isEqualTo( 1 );

    session.clear();

    transaction = session.beginTransaction();
    cloud = (Cloud) session.get( Cloud.class, cloud.getId() );
    assertNotNull( cloud.getProducedSnowFlakes() );
    assertEquals( 2, cloud.getProducedSnowFlakes().size() );
View Full Code Here

    transaction.commit();

    assertThat( getNumberOfEntities( sessions ) ).isEqualTo( 4 );
    assertThat( getNumberOfAssociations( sessions ) ).isEqualTo( 1 );

    session.clear();

    transaction = session.beginTransaction();
    cloud = (Cloud) session.get( Cloud.class, cloud.getId() );
    assertNotNull( cloud.getProducedSnowFlakes() );
    assertEquals( 2, cloud.getProducedSnowFlakes().size() );
View Full Code Here

    Galaxy entity = (Galaxy) session.get( Galaxy.class, galaxy.getId() );
    entity.getStars().add( new Star( "Algol" ) );

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

    session = openSession();
    transaction = session.beginTransaction();

    entity = (Galaxy) session.get( Galaxy.class, galaxy.getId() );
View Full Code Here

    transaction.commit();

    assertThat( getNumberOfEntities( sessions ) ).isEqualTo( 1 );
    assertThat( getNumberOfAssociations( sessions ) ).isEqualTo( 0 );

    session.clear();

    transaction = session.beginTransaction();
    cloud = (Cloud) session.get( Cloud.class, cloud.getId() );
    assertNotNull( cloud.getProducedSnowFlakes() );
    assertEquals( 0, cloud.getProducedSnowFlakes().size() );
View Full Code Here

    father.getOrderedChildren().add( null );
    father.getOrderedChildren().add( leia );
    session.persist( father );
    tx.commit();

    session.clear();

    tx = session.beginTransaction();
    father = (Father) session.get( Father.class, father.getId() );
    assertThat( father.getOrderedChildren() )
        .as( "List should have 3 elements" )
View Full Code Here

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

    session.clear();

    //do an update to one of the elements
    tx = session.beginTransaction();
    grandMother = (GrandMother) session.get( GrandMother.class, grandMother.getId() );
    assertThat( grandMother.getGrandChildren() ).onProperty( "name" ).containsExactly( "Luke", "Leia" );
View Full Code Here

    grandMother = (GrandMother) session.get( GrandMother.class, grandMother.getId() );
    assertThat( grandMother.getGrandChildren() ).onProperty( "name" ).containsExactly( "Luke", "Leia" );
    grandMother.getGrandChildren().get( 0 ).setName( "Lisa" );

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

    //assert update has been propagated
    tx = session.beginTransaction();
    grandMother = (GrandMother) session.get( GrandMother.class, grandMother.getId() );
    assertThat( grandMother.getGrandChildren() ).onProperty( "name" ).containsExactly( "Lisa", "Leia" );
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.