Package org.restsql.core.SqlBuilder

Examples of org.restsql.core.SqlBuilder.SqlStruct


    request.extractParameters();
    TriggerManager.executeTriggers(getName(), request, true);

    final Object results;
    Connection connection = null;
    final SqlStruct sqlStruct = sqlBuilder.buildSelectSql(metaData, definition.getQuery().getValue(),
        request);
    try {
      connection = Factory.getConnection(SqlResourceDefinitionUtils.getDefaultDatabase(definition));
      final PreparedStatement statement = connection.prepareStatement(sqlStruct.getPreparedStatement());
      if (Config.logger.isDebugEnabled()) {
        Config.logger.debug("\n" + sqlStruct.getPreparedStatement() + "\n-----\n"
            + sqlStruct.getStatement());
      }
      request.getLogger().addSql(sqlStruct.getStatement());
      for (int i = 0; i < sqlStruct.getPreparedValues().size(); i++) {
        statement.setObject(i + 1, sqlStruct.getPreparedValues().get(i));
      }
      final ResultSet resultSet = statement.executeQuery();
      if (metaData.isHierarchical()) {
        if (contentType != null) {
          results = Factory.getResponseSerializer(contentType).serializeReadHierarchical(this,
              buildReadResultsHierachicalCollection(resultSet));
        } else {
          results = buildReadResultsHierachicalCollection(resultSet);
        }
      } else {
        if (contentType != null) {
          results = Factory.getResponseSerializer(contentType).serializeReadFlat(this, resultSet);
        } else {
          results = buildReadResultsFlatCollection(resultSet);
        }
      }
      resultSet.close();
      statement.close();
    } catch (final SQLException exception) {
      throw new SqlResourceException(exception, sqlStruct.getStatement());
    } finally {
      if (connection != null) {
        try {
          connection.close();
        } catch (final SQLException ignored) {
View Full Code Here

TOP

Related Classes of org.restsql.core.SqlBuilder.SqlStruct

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.