org.jooq.Query Maven / Gradle / Ivy
Show all versions of payment-retries-plugin Show documentation
/*
* Copyright (c) 2009-2016, Data Geekery GmbH (http://www.datageekery.com)
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Other licenses:
* -----------------------------------------------------------------------------
* Commercial licenses for this work are available. These replace the above
* ASL 2.0 and offer limited warranties, support, maintenance, and commercial
* database integrations.
*
* For more information, please visit: http://www.jooq.org/licenses
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
package org.jooq;
import java.sql.PreparedStatement;
import java.sql.Statement;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.Executor;
import org.jooq.conf.ParamType;
import org.jooq.conf.Settings;
import org.jooq.conf.StatementType;
import org.jooq.exception.DataAccessException;
import org.jooq.exception.DataTypeException;
import org.jooq.impl.DSL;
/**
* Any query
*
* @author Lukas Eder
*/
public interface Query extends QueryPart, Attachable , AutoCloseable {
/**
* Execute the query, if it has been created with a proper configuration.
*
* @return A result value, depending on the concrete implementation of
* {@link Query}:
*
* - {@link Delete} : the number of deleted records
* - {@link Insert} : the number of inserted records
* - {@link Merge} : the result may have no meaning
* - {@link Select} : the number of resulting records
* - {@link Truncate} : the result may have no meaning
* - {@link Update} : the number of updated records
*
* @throws DataAccessException If anything goes wrong in the database
*/
int execute() throws DataAccessException;
/**
* Execute the query in a new {@link CompletionStage}.
*
* The result is asynchronously completed by a task running in an
* {@link Executor} provided by the underlying
* {@link Configuration#executorProvider()}.
*
* @return A result value, depending on the concrete implementation of
* {@link Query}:
*
* - {@link Delete} : the number of deleted records
* - {@link Insert} : the number of inserted records
* - {@link Merge} : the result may have no meaning
* - {@link Select} : the number of resulting records
* - {@link Truncate} : the result may have no meaning
* - {@link Update} : the number of updated records
*
*/
CompletionStage executeAsync();
/**
* Execute the query in a new {@link CompletionStage} that is asynchronously
* completed by a task running in the given executor.
*
* @return A result value, depending on the concrete implementation of
* {@link Query}:
*
* - {@link Delete} : the number of deleted records
* - {@link Insert} : the number of inserted records
* - {@link Merge} : the result may have no meaning
* - {@link Select} : the number of resulting records
* - {@link Truncate} : the result may have no meaning
* - {@link Update} : the number of updated records
*
*/
CompletionStage executeAsync(Executor executor);
/**
* Whether this query is executable in its current state.
*
* DML queries may be incomplete in structure and thus not executable.
* Calling {@link #execute()} on such queries has no effect, but beware that
* {@link #getSQL()} may not render valid SQL!
*/
boolean isExecutable();
/**
* Retrieve the SQL code rendered by this Query.
*
* Use this method, when you want to use jOOQ for object oriented query
* creation, but execute the query with some other technology, such as
*
* - JDBC
* - Spring Templates
* - JPA native queries
* - etc...
*
*
* Note, this is the same as calling {@link #getSQL(boolean)}. The boolean
* parameter will depend on your {@link DSLContext}'s {@link Settings}:
*
*
* StatementType
* boolean parameter
* effect
*
*
* {@link StatementType#PREPARED_STATEMENT}
* false
(default)
* This will render bind variables to be used with a JDBC
* {@link PreparedStatement}. You can extract bind values from this
* Query
using {@link #getBindValues()}
*
*
* {@link StatementType#STATIC_STATEMENT}
* true
* This will inline all bind variables in a statement to be used with a
* JDBC {@link Statement}
*
*
*
* [#1520] Note that the query actually being executed might not contain any
* bind variables, in case the number of bind variables exceeds your SQL
* dialect's maximum number of supported bind variables. This is not
* reflected by this method, which will only use the {@link Settings} to
* decide whether to render bind values.
*
* @see #getSQL(boolean)
*/
String getSQL();
/**
* Retrieve the SQL code rendered by this Query.
*
* [#1520] Note that the query actually being executed might not contain any
* bind variables, in case the number of bind variables exceeds your SQL
* dialect's maximum number of supported bind variables. This is not
* reflected by this method, which will only use inline
* argument to decide whether to render bind values.
*
* See {@link #getSQL()} for more details.
*
* @param inline Whether to inline bind variables. This overrides values in
* {@link Settings#getStatementType()}
* @return The generated SQL
* @deprecated - [#2414] - 3.1.0 - Use {@link #getSQL(ParamType)} instead
*/
@Deprecated
String getSQL(boolean inline);
/**
* Retrieve the SQL code rendered by this Query.
*
* [#1520] Note that the query actually being executed might not contain any
* bind variables, in case the number of bind variables exceeds your SQL
* dialect's maximum number of supported bind variables. This is not
* reflected by this method, which will only use paramType
* argument to decide whether to render bind values.
*
* See {@link #getSQL()} for more details.
*
* @param paramType How to render parameters. This overrides values in
* {@link Settings#getStatementType()}
* @return The generated SQL
*/
String getSQL(ParamType paramType);
/**
* Retrieve the bind values that will be bound by this Query. This
* List
cannot be modified. To modify bind values, use
* {@link #getParams()} instead.
*
* Unlike {@link #getParams()}, which returns also inlined parameters, this
* returns only actual bind values that will render an actual bind value as
* a question mark "?"
*
* @see DSLContext#extractBindValues(QueryPart)
*/
List