Пример #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
  @Override
  protected List getResultList(List results, ResultTransformer resultTransformer)
      throws QueryException {
    // meant to handle dynamic instantiation queries...(Copy from QueryLoader)
    HolderInstantiator holderInstantiator =
        HolderInstantiator.getHolderInstantiator(
            null, resultTransformer, getReturnAliasesForTransformer());
    if (holderInstantiator.isRequired()) {
      for (int i = 0; i < results.size(); i++) {
        Object[] row = (Object[]) results.get(i);
        Object result = holderInstantiator.instantiate(row);
        results.set(i, result);
      }

      return resultTransformer.transformList(results);
    } else {
      return results;
    }
  }
Пример #3
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 {
      final List<AfterLoadAction> afterLoadActions = new ArrayList<AfterLoadAction>();
      final ResultSet rs = executeQueryStatement(queryParameters, false, afterLoadActions, session);
      final PreparedStatement st = (PreparedStatement) rs.getStatement();
      HolderInstantiator hi =
          HolderInstantiator.createClassicHolderInstantiator(
              holderConstructor, queryParameters.getResultTransformer());
      Iterator result =
          new IteratorImpl(
              rs,
              st,
              session,
              queryParameters.isReadOnly(session),
              returnTypes,
              getColumnNames(),
              hi);

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

      return result;

    } catch (SQLException sqle) {
      throw getFactory()
          .getSQLExceptionHelper()
          .convert(sqle, "could not execute query using iterate", getSQLString());
    }
  }
Пример #4
0
 @Override
 protected ResultTransformer resolveResultTransformer(ResultTransformer resultTransformer) {
   return HolderInstantiator.resolveResultTransformer(null, resultTransformer);
 }
Пример #5
0
 @Override
 protected ResultTransformer resolveResultTransformer(ResultTransformer resultTransformer) {
   return HolderInstantiator.resolveClassicResultTransformer(holderConstructor, resultTransformer);
 }