Class SqlQuery

java.lang.Object
org.dalesbred.query.SqlQuery
All Implemented Interfaces:
Serializable

public final class SqlQuery extends Object implements Serializable
Represents an SQL query along all of its arguments.
See Also:
  • Method Details

    • query

      @NotNull public static @NotNull SqlQuery query(@NotNull @NotNull String sql, Object... args)
      Creates a new SqlQuery consisting of given SQL statement and arguments. '?' characters act as placeholders for arguments in the query.
    • query

      @NotNull public static @NotNull SqlQuery query(@NotNull @NotNull String sql, @NotNull @NotNull List<?> args)
      See Also:
    • namedQuery

      @NotNull public static @NotNull SqlQuery namedQuery(@NotNull @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 @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 @NotNull String sql, @NotNull @NotNull VariableResolver variableResolver)
      Creates a new SqlQuery consisting 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 malformed
      VariableResolutionException - if variableResolver can't provide values for named parameters
    • getSql

      @NotNull public @NotNull String 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

      @NotNull public @NotNull List<?> getArguments()
      Returns the list of arguments this query has.
    • getFetchSize

      @Nullable public @Nullable Integer getFetchSize()
      Returns the fetch size of this query.
    • setFetchSize

      public void setFetchSize(@Nullable @Nullable Integer size)
      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

      @Nullable public @Nullable FetchDirection getFetchDirection()
      Returns the fetch direction of this query.
    • setFetchDirection

      public void setFetchDirection(@Nullable @Nullable FetchDirection direction)
      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

      @Nullable public @Nullable Duration getTimeout()
      Returns the timeout of this query.
    • setTimeout

      public void setTimeout(@NotNull @NotNull Duration timeout)
      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

      @NotNull public @NotNull String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object