コード例 #1
0
 public ScrollableResults scroll(
     final QueryParameters queryParameters, final SessionImplementor session)
     throws HibernateException {
   HolderInstantiator hi =
       HolderInstantiator.createClassicHolderInstantiator(
           holderConstructor, queryParameters.getResultTransformer());
   return scroll(queryParameters, returnTypes, hi, session);
 }
コード例 #2
0
  /** Return the query results as an iterator */
  public Iterator iterate(QueryParameters queryParameters, EventSource session)
      throws HibernateException {

    boolean stats = session.getFactory().getStatistics().isStatisticsEnabled();
    long startTime = 0;
    if (stats) startTime = System.currentTimeMillis();

    try {

      PreparedStatement st = prepareQueryStatement(queryParameters, false, session);
      ResultSet rs =
          getResultSet(
              st,
              queryParameters.hasAutoDiscoverScalarTypes(),
              false,
              queryParameters.getRowSelection(),
              session);
      HolderInstantiator hi =
          HolderInstantiator.createClassicHolderInstantiator(
              holderConstructor, queryParameters.getResultTransformer());
      Iterator result = new IteratorImpl(rs, st, session, returnTypes, getColumnNames(), hi);

      if (stats) {
        session
            .getFactory()
            .getStatisticsImplementor()
            .queryExecuted("HQL: " + queryString, 0, System.currentTimeMillis() - startTime);
      }

      return result;

    } catch (SQLException sqle) {
      throw JDBCExceptionHelper.convert(
          getFactory().getSQLExceptionConverter(),
          sqle,
          "could not execute query using iterate",
          getSQLString());
    }
  }