Package org.hibernate

Examples of org.hibernate.StatelessSession


                assert invokeMethod("#{uploadHome.persist}").equals("persisted");
            }

            protected void renderResponse() throws Exception {
                StatelessSession ss = getStatelessSession();
                List<String> uploads =
                        ss.createQuery("select wu.filename from WikiUpload wu where wu.parent.id = :parent order by wu.createdOn desc ")
                        .setParameter("parent" , 2l).list();

                assert uploads.size() == 3;
                assert uploads.get(0).equals("testupload2.zip");
            }
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) {
          errorHandler.handleException( log.massIndexerUnexpectedErrorMessage() , e);
          try {
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 = session.getTransaction();
      transaction.begin();
      loadAllIdentifiers( session );
      transaction.commit();
    }
    catch (InterruptedException e) {
      // just quit
      Thread.currentThread().interrupt();
    }
    finally {
      if ( upperSession == null ) {
        session.close();
      }
    }
  }
View Full Code Here

  @Override
  public void runWithErrorHandler() throws Exception {
    if ( wrapInTransaction ) {
      final Session session;
      final StatelessSession statelessSession;
      if ( sessionAwareRunnable != null ) {
        session = batchContext.factory.openSession();
        statelessSession = null;
      }
      else {
        session = null;
        statelessSession = batchContext.factory.openStatelessSession();
      }

      batchContext.transactionManager.begin();

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

      batchContext.transactionManager.commit();

      if ( sessionAwareRunnable != null ) {
        session.close();
      }
      else {
        statelessSession.close();
      }
    }
    else {
      if ( sessionAwareRunnable != null ) {
        sessionAwareRunnable.run( null );
View Full Code Here

  @Override
  public void runWithErrorHandler() throws Exception {
    if ( wrapInTransaction ) {
      final Session session;
      final StatelessSession statelessSession;
      if ( sessionAwareRunnable != null ) {
        session = batchContext.factory.openSession();
        statelessSession = null;
      }
      else {
        session = null;
        statelessSession = batchContext.factory.openStatelessSession();
      }

      batchContext.transactionManager.begin();

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

      batchContext.transactionManager.commit();

      if ( sessionAwareRunnable != null ) {
        session.close();
      }
      else {
        statelessSession.close();
      }
    }
    else {
      if ( sessionAwareRunnable != null ) {
        sessionAwareRunnable.run( null );
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 = session.getTransaction();
      transaction.begin();
      loadAllIdentifiers( session );
      transaction.commit();
    }
    catch (InterruptedException e) {
      // just quit
      Thread.currentThread().interrupt();
    }
    finally {
      if ( upperSession == null ) {
        session.close();
      }
    }
  }
View Full Code Here

    public void migrate() throws Exception {
        performMigration(Task.Migrate);
    }

    private long getRowCount(String countQuery) {
        StatelessSession session = getSQLSession(config);

        org.hibernate.Query query = session.createSQLQuery(countQuery);
        query.setReadOnly(true);
        query.setTimeout(DataMigrator.SQL_TIMEOUT);

        long count = Long.parseLong(query.uniqueResult().toString());
View Full Code Here

    private void deleteTableData(String table) throws Exception {
        String deleteQuery = String.format(MigrationQuery.DELETE_RAW_ENTRY.toString(), table);
        int failureCount = 0;
        while (failureCount < MAX_NUMBER_OF_FAILURES) {
            try {
                StatelessSession session = getSQLSession(config);
                session.getTransaction().begin();
                org.hibernate.Query nativeQuery = session.createSQLQuery(deleteQuery);
                nativeQuery.executeUpdate();
                session.getTransaction().commit();
                closeSQLSession(session);
                log.info("- " + table + " - Cleaned -");
            } catch (Exception e) {
                log.error("Failed to delete " + table + " data. Attempting to delete data one more time...");
View Full Code Here

        accumulator.clear();
        currentCount = 0;
    }

    private long getLastAggregationTime(MigrationTable migratedTable) {
        StatelessSession session = getSQLSession(migratorConfiguration);

        long aggregationSlice = Integer.MAX_VALUE;
        Duration duration = null;
        String queryString = null;

        if (MigrationTable.RAW.equals(migratedTable)) {
            duration = metricsConfiguration.getRawTimeSliceDuration();
            queryString = MigrationQuery.MAX_TIMESTAMP_1H_DATA.toString();
        } else if (MigrationTable.ONE_HOUR.equals(migratedTable)) {
            duration = metricsConfiguration.getOneHourTimeSliceDuration();
            queryString = MigrationQuery.MAX_TIMESTAMP_6H_DATA.toString();
        } else if (MigrationTable.SIX_HOUR.equals(migratedTable)) {
            duration = metricsConfiguration.getSixHourTimeSliceDuration();
            queryString = MigrationQuery.MAX_TIMESTAMP_1D_DATA.toString();
        }

        if (duration != null && queryString != null) {
            Query query = session.createSQLQuery(queryString);

            Long timeStamp;
            Object result = query.uniqueResult();
            if(result != null){
                String queryResult = query.uniqueResult().toString();
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.