Package org.hibernate

Examples of org.hibernate.Session.clear()


      Helicopter entity = helicopter( "Honey Bee CP3" );
      Transaction tx = session.beginTransaction();
      session.persist( entity );
      uuid = entity.getUUID();
      tx.commit();
      session.clear();
    }
    {
      Transaction tx = session.beginTransaction();
      Helicopter entity = (Helicopter) session.get( Helicopter.class, uuid );
      entity.setName( null );
View Full Code Here


    final Integer stockCount = Integer.valueOf( RANDOM.nextInt() );
    b.setStockCount( stockCount );

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

    transaction = session.beginTransaction();
    b = (Bookmark) session.get( Bookmark.class, b.getId() );

    //Check directly in the cache the values stored
View Full Code Here

    {
      Transaction tx = session.beginTransaction();
      Helicopter entity = (Helicopter) session.get( Helicopter.class, uuid );
      entity.setName( null );
      tx.commit();
      session.clear();
    }
    {
      Transaction tx = session.beginTransaction();
      Helicopter entity = (Helicopter) session.get( Helicopter.class, uuid );
      session.delete( entity );
View Full Code Here

    hyp.setDescription( "NP != P" );
    hyp.setPosition( 1 );
    session.persist( hyp );
    transaction.commit();

    session.clear();

    transaction = session.beginTransaction();
    final Hypothesis loadedHyp = (Hypothesis) session.get( Hypothesis.class, hyp.getId() );
    assertNotNull( "Cannot load persisted object", loadedHyp );
    assertEquals( "persist and load fails", hyp.getDescription(), loadedHyp.getDescription() );
View Full Code Here

    assertNotNull( "Cannot load persisted object", loadedHyp );
    assertEquals( "persist and load fails", hyp.getDescription(), loadedHyp.getDescription() );
    assertEquals( "@Column fails", hyp.getPosition(), loadedHyp.getPosition() );
    transaction.commit();

    session.clear();

    transaction = session.beginTransaction();
    loadedHyp.setDescription( "P != NP");
    session.merge( loadedHyp );
    transaction.commit();
View Full Code Here

    transaction = session.beginTransaction();
    loadedHyp.setDescription( "P != NP");
    session.merge( loadedHyp );
    transaction.commit();

    session.clear();

    transaction = session.beginTransaction();
    Hypothesis secondLoadedHyp = (Hypothesis) session.get( Hypothesis.class, hyp.getId() );
    assertEquals( "Merge fails", loadedHyp.getDescription(), secondLoadedHyp.getDescription() );
    session.delete( secondLoadedHyp );
View Full Code Here

    Hypothesis secondLoadedHyp = (Hypothesis) session.get( Hypothesis.class, hyp.getId() );
    assertEquals( "Merge fails", loadedHyp.getDescription(), secondLoadedHyp.getDescription() );
    session.delete( secondLoadedHyp );
    transaction.commit();

    session.clear();

    transaction = session.beginTransaction();
    assertNull( session.get( Hypothesis.class, hyp.getId() ) );
    transaction.commit();
View Full Code Here

    Helicopter h = new Helicopter();
    h.setName( "Eurocopter" );
    session.persist( h );
    transaction.commit();

    session.clear();

    transaction = session.beginTransaction();
    h = (Helicopter) session.get( Helicopter.class, h.getUUID() );
    session.delete( h );
    transaction.commit();
View Full Code Here

      Transaction transaction = session.beginTransaction();
      Insurance insurance = new Insurance();
      insurance.setName( "Insurance Corporation" );
      session.persist( insurance );
      transaction.commit();
      session.clear();
      session.close();
    }
    {
      purgeAll( Insurance.class );
      startAndWaitMassIndexing( Insurance.class );
View Full Code Here

      @SuppressWarnings("unchecked")
      List<Insurance> list = session.createFullTextQuery( luceneQuery ).list();
      assertThat( list ).hasSize( 1 );
      assertThat( list.get( 0 ).getName() ).isEqualTo( "Insurance Corporation" );
      transaction.commit();
      session.clear();
      session.close();
    }
  }

  @Test
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.