Package org.hibernate

Examples of org.hibernate.StatelessSession


    }
    log.trace( "finished" );
  }

  private void inTransactionWrapper() {
    StatelessSession session = sessionFactory.openStatelessSession();
    try {
      Transaction transaction = session.beginTransaction();
      loadAllIdentifiers( session );
      transaction.commit();
    } catch (InterruptedException e) {
      // just quit
    }
    finally {
      session.close();
    }
  }
View Full Code Here


    }
    log.trace( "finished" );
  }

  private void inTransactionWrapper(StatelessSession upperSession) throws Exception {
    StatelessSession session = upperSession;
    if (upperSession == null) {
      session = sessionFactory.openStatelessSession();
    }
    try {
      Transaction transaction = Helper.getTransactionAndMarkForJoin( session );
      transaction.begin();
      loadAllIdentifiers( session );
      transaction.commit();
    } catch (InterruptedException e) {
      // just quit
      Thread.currentThread().interrupt();
    }
    finally {
      if (upperSession == null) {
        session.close();
      }
    }
  }
View Full Code Here

    final boolean wrapInTransaction = wrapInTransaction();
    if ( wrapInTransaction ) {
      TransactionManager transactionManager = getTransactionManager();
      try {
        final Session session;
        final StatelessSession statelessSession;
        if ( sessionAwareRunnable != null ) {
          session = factory.openSession();
          statelessSession = null;
        }
        else {
          session = null;
          statelessSession = factory.openStatelessSession();
        }

        transactionManager.begin();

        if ( sessionAwareRunnable != null ) {
          sessionAwareRunnable.run( session );
        }
        else {
          statelessSessionAwareRunnable.run( statelessSession );
        }

        transactionManager.commit();

        if ( sessionAwareRunnable != null ) {
          session.close();
        }
        else {
          statelessSession.close();
        }
      }
      catch (Throwable e) {
        //TODO exception handling seems messy-ish
        log.errorExecutingRunnableInTransaction( e );
View Full Code Here

    }
    log.trace( "finished" );
  }

  private void inTransactionWrapper(StatelessSession upperSession) throws Exception {
    StatelessSession session = upperSession;
    if (upperSession == null) {
      session = sessionFactory.openStatelessSession();
    }
    try {
      Transaction transaction = Helper.getTransactionAndMarkForJoin( session );
      transaction.begin();
      loadAllIdentifiers( session );
      transaction.commit();
    } catch (InterruptedException e) {
      // just quit
      Thread.currentThread().interrupt();
    }
    finally {
      if (upperSession == null) {
        session.close();
      }
    }
  }
View Full Code Here

    }
    log.trace( "finished" );
  }

  private void inTransactionWrapper(StatelessSession upperSession) throws Exception {
    StatelessSession session = upperSession;
    if (upperSession == null) {
      session = sessionFactory.openStatelessSession();
    }
    try {
      Transaction transaction = Helper.getTransactionAndMarkForJoin( session );
      transaction.begin();
      loadAllIdentifiers( session );
      transaction.commit();
    } catch (InterruptedException e) {
      // just quit
      Thread.currentThread().interrupt();
    }
    finally {
      if (upperSession == null) {
        session.close();
      }
    }
  }
View Full Code Here

  @Test
  public void testCreateQueryWithStatelessSession() {
    String sqlQuery = "select * from T_FOOS";
    hibernateQueryProvider.setSqlQuery(sqlQuery);

    StatelessSession session = mock(StatelessSession.class);
    SQLQuery query = mock(SQLQuery.class);

    when(session.createSQLQuery(sqlQuery)).thenReturn(query);
    when(query.addEntity(Foo.class)).thenReturn(query);

    hibernateQueryProvider.setStatelessSession(session);
    Assert.notNull(hibernateQueryProvider.createQuery());

View Full Code Here

  private SessionFactory sessionFactory = mock(SessionFactory.class);
 
  @Test
  public void testOneSessionForAllPages() throws Exception {

    StatelessSession session = mock(StatelessSession.class);
    when(sessionFactory.openStatelessSession()).thenReturn(session);
   
    helper.setSessionFactory(sessionFactory);

    helper.createQuery();
View Full Code Here

  }

  @Test
  public void testSessionReset() throws Exception {

    StatelessSession session = mock(StatelessSession.class);
    when(sessionFactory.openStatelessSession()).thenReturn(session);
   
    helper.setSessionFactory(sessionFactory);

    helper.createQuery();
View Full Code Here

    final boolean wrapInTransaction = wrapInTransaction();
    if ( wrapInTransaction ) {
      TransactionManager transactionManager = factory.getTransactionManager();
      try {
        final Session session;
        final StatelessSession statelessSession;
        if ( sessionAwareRunnable != null ) {
          session = factory.openSession();
          statelessSession = null;
        }
        else {
          session = null;
          statelessSession = factory.openStatelessSession();
        }

        transactionManager.begin();

        if ( sessionAwareRunnable != null ) {
          sessionAwareRunnable.run( session );
        }
        else {
          statelessSessionAwareRunnable.run( statelessSession );
        }

        transactionManager.commit();

        if ( sessionAwareRunnable != null ) {
          session.close();
        }
        else {
          statelessSession.close();
        }
      }
      catch (Throwable e) {
        //TODO exception handling seems messy-ish
        log.error( "Error while executing runnable wrapped in a JTA transaction", e );
View Full Code Here

    }
    log.trace( "finished" );
  }

  private void inTransactionWrapper(StatelessSession upperSession) throws Exception {
    StatelessSession session = upperSession;
    if (upperSession == null) {
      session = sessionFactory.openStatelessSession();
    }
    try {
      Transaction transaction = Helper.getTransactionAndMarkForJoin( session );
      transaction.begin();
      loadAllIdentifiers( session );
      transaction.commit();
    } catch (InterruptedException e) {
      // just quit
    }
    finally {
      if (upperSession == null) {
        session.close();
      }
    }
  }
View Full Code Here

TOP

Related Classes of org.hibernate.StatelessSession

Copyright © 2018 www.massapicom. 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.