Пример #1
0
  /**
   * Compile the query (generate the SQL).
   *
   * @throws org.hibernate.MappingException Indicates problems resolving things referenced in the
   *     query.
   * @throws org.hibernate.QueryException Generally some form of syntatic failure.
   */
  private void compile() throws QueryException, MappingException {
    LOG.trace("Compiling query");
    try {
      ParserHelper.parse(
          new PreprocessingParser(tokenReplacements),
          queryString,
          ParserHelper.HQL_SEPARATORS,
          this);
      renderSQL();
    } catch (QueryException qe) {
      qe.setQueryString(queryString);
      throw qe;
    } catch (MappingException me) {
      throw me;
    } catch (Exception e) {
      LOG.debug("Unexpected query compilation problem", e);
      e.printStackTrace();
      QueryException qe = new QueryException("Incorrect query syntax", e);
      qe.setQueryString(queryString);
      throw qe;
    }

    postInstantiate();

    compiled = true;
  }
 public int[] getNamedParameterLocs(String name) throws QueryException {
   Object o = namedParameters.get(name);
   if (o == null) {
     QueryException qe = new QueryException(ERROR_NAMED_PARAMETER_DOES_NOT_APPEAR + name);
     qe.setQueryString(queryString);
     throw qe;
   }
   if (o instanceof Integer) {
     return new int[] {((Integer) o).intValue()};
   } else {
     return ArrayHelper.toIntArray((ArrayList) o);
   }
 }