Package org.hibernate

Examples of org.hibernate.Session.clear()


        UserBean user = (UserBean)users.get(i);
        msg.setToUser(user);
        ssn.save(msg);
        if(i % 20 == 0){
          ssn.flush();
          ssn.clear();
        }
      }
      commit();
    }catch(HibernateException e){
      rollback();
View Full Code Here


    Session s = SESSION.get();
    if (s != null) {
      LOG.log(Level.WARNING, "Openning session more than once from the same thread!",
        new Exception("Dump"));

      s.clear();

      return s;
    } else
    {
      try {
View Full Code Here

    Transaction transaction = session.beginTransaction();
    session.persist( portia );
    session.persist( athanasia );
    session.persist( ballade );
    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, ballade);
    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

        .list();

    assertThat( result ).containsExactly( ballade );

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

  @Override
  protected Class<?>[] getAnnotatedClasses() {
View Full Code Here

    flower.setId( "1" );
    flower.setName( "Caltha palustris" );

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

    transaction = session.beginTransaction();

    Flower loadedFlower = (Flower) session.get( Flower.class, flower.getId() );
    assertNotNull( loadedFlower );
View Full Code Here

    Flower loadedFlower = (Flower) session.get( Flower.class, flower.getId() );
    assertNotNull( loadedFlower );
    assertEquals( flower.getName(), loadedFlower.getName() );

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

  private static OgmConfiguration getConfiguration() {
    OgmConfiguration configuration = TestHelper.getDefaultTestConfiguration( Flower.class );
View Full Code Here

    hypothesis.setPosition( 8 );
    hypothesis.setDescription( "100\nscientiae" );
    session.persist( hypothesis );

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

  @AfterClass
  public static void deleteTestEntities() throws Exception {
View Full Code Here

    session.delete( new Hypothesis( "6" ) );
    session.delete( new Hypothesis( "7" ) );
    session.delete( new Hypothesis( "8" ) );

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

  @Before
  public void startTransaction() {
View Full Code Here

    Helicopter helicopter = (Helicopter) query.uniqueResult();
    assertThat( helicopter ).isNotNull();
    helicopter.setName( "Leonie" );

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

    query = session.createQuery( "from Helicopter h where name = 'Leonie'" );
    helicopter = (Helicopter) query.uniqueResult();
    assertThat( helicopter ).isNotNull();
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.