Package org.dalesbred.query
Class SqlQuery
java.lang.Object
org.dalesbred.query.SqlQuery
- All Implemented Interfaces:
Serializable
Represents an SQL query along all of its arguments.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionboolean@NotNull List<?> Returns the list of arguments this query has.@Nullable FetchDirectionReturns the fetch direction of this query.@Nullable IntegerReturns the fetch size of this query.@NotNull StringgetSql()Returns the SQL that is to be execute at the database.@Nullable DurationReturns the timeout of this query.inthashCode()static @NotNull SqlQuerynamedQuery(@NotNull String sql, @NotNull Object bean) Constructs a query with named arguments, using the properties/fields of given bean for resolving arguments.static @NotNull SqlQuerynamedQuery(@NotNull String sql, @NotNull Map<String, ?> valueMap) Constructs a query with named arguments, using given map for resolving the values of arguments.static @NotNull SqlQuerynamedQuery(@NotNull String sql, @NotNull VariableResolver variableResolver) Creates a newSqlQueryconsisting of given SQL statement and a provider for named arguments.static @NotNull SqlQueryCreates a newSqlQueryconsisting of given SQL statement and arguments.static @NotNull SqlQueryvoidsetFetchDirection(@Nullable FetchDirection direction) A non-null fetch direction will be set as the fetch direction for the statements executed from this query.voidsetFetchSize(@Nullable Integer size) A non-null fetch size will be set as the fetch size for the statements executed from this query.voidsetTimeout(@NotNull Duration timeout) A non-null timeout will be set as the timeout for the statements executed from this query.@NotNull StringtoString()
-
Method Details
-
query
@NotNull public static @NotNull SqlQuery query(@NotNull @Language("SQL") @NotNull String sql, Object... args) Creates a newSqlQueryconsisting of given SQL statement and arguments. '?' characters act as placeholders for arguments in the query. -
query
@NotNull public static @NotNull SqlQuery query(@NotNull @Language("SQL") @NotNull String sql, @NotNull @NotNull List<?> args) - See Also:
-
namedQuery
@NotNull public static @NotNull SqlQuery namedQuery(@NotNull @Language("SQL") @NotNull String sql, @NotNull @NotNull Map<String, ?> valueMap) Constructs a query with named arguments, using given map for resolving the values of arguments.- See Also:
-
namedQuery
@NotNull public static @NotNull SqlQuery namedQuery(@NotNull @Language("SQL") @NotNull String sql, @NotNull @NotNull Object bean) Constructs a query with named arguments, using the properties/fields of given bean for resolving arguments.- See Also:
-
namedQuery
@NotNull public static @NotNull SqlQuery namedQuery(@NotNull @Language("SQL") @NotNull String sql, @NotNull @NotNull VariableResolver variableResolver) Creates a newSqlQueryconsisting of given SQL statement and a provider for named arguments. The argument names in SQL should be prefixed by a colon, e.g. ":argument".- Throws:
SqlSyntaxException- if SQL is malformedVariableResolutionException- if variableResolver can't provide values for named parameters
-
getSql
Returns the SQL that is to be execute at the database. If the original query was a named query, the variable placeholders will have been replaced by positional placeholders in this query. -
getArguments
Returns the list of arguments this query has. -
getFetchSize
Returns the fetch size of this query. -
setFetchSize
A non-null fetch size will be set as the fetch size for the statements executed from this query. If the fetch size specified is zero, the JDBC driver ignores the value and makes its own best guess of the fetch size.- Parameters:
size- fetch size in rows or null- Throws:
IllegalArgumentException- if size is < 0
-
getFetchDirection
Returns the fetch direction of this query. -
setFetchDirection
A non-null fetch direction will be set as the fetch direction for the statements executed from this query.- Parameters:
direction- fetch direction or null
-
getTimeout
Returns the timeout of this query. -
setTimeout
A non-null timeout will be set as the timeout for the statements executed from this query. If the timeout specified is zero, there is no limit for execution time- Throws:
IllegalArgumentException- if timeout is negative- See Also:
-
toString
-
equals
-
hashCode
public int hashCode()
-