Class SqlFragment

java.lang.Object
org.apache.juneau.beanquery.sql.SqlFragment

public final class SqlFragment extends Object
A parameterized SQL predicate fragment: a boolean SQL expression plus the ordered bind values its ? placeholders consume.

A SearchSqlRenderer for a custom operator returns one of these; the SQL context splices the sql() into the assembled WHERE clause and appends the binds() to the prepared-statement parameter list in order. Values are always bound as parameters (never string-concatenated) so a custom operator cannot open an injection hole.

Since:
10.0.0
  • Method Details

    • of

      public static SqlFragment of(String sql, List<Object> binds)
      Creates a fragment.
      Parameters:
      sql - The boolean SQL expression, with ? placeholders for each bind value. Must not be null or blank.
      binds - The bind values, in placeholder order. May be empty; must not be null.
      Returns:
      A new fragment.
    • of

      public static SqlFragment of(String sql, Object... binds)
      Creates a fragment from a varargs bind list.
      Parameters:
      sql - The boolean SQL expression, with ? placeholders for each bind value. Must not be null or blank.
      binds - The bind values, in placeholder order.
      Returns:
      A new fragment.
    • sql

      public String sql()
      The boolean SQL expression.
      Returns:
      The SQL, never null or blank.
    • binds

      public List<Object> binds()
      The bind values in placeholder order.
      Returns:
      An unmodifiable list of bind values, never null.
    • toString

      public String toString()
      Overrides:
      toString in class Object