Package org.postgresql.core

# Class NativeQuery

java.lang.Object
org.postgresql.core.NativeQuery

public class NativeQuery extends Object
Represents a query that is ready for execution by backend. The main difference from JDBC is ? are replaced with $1, $2, etc.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `final int[]`
  `bindPositions`
  `final SqlCommand`
  `command`
  `final boolean`
  `multiStatement`
  `final String`
  `nativeSql`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `NativeQuery(String nativeSql, int @Nullable [] bindPositions, boolean multiStatement, SqlCommand dml)`
  `NativeQuery(String nativeSql, SqlCommand dml)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static StringBuilder`
  `appendBindName(StringBuilder sb, int index)`
  `static String`
  `bindName(int index)`
  Returns $1, $2, etc names of bind variables used by backend.
  `static int`
  `calculateBindLength(int bindCount)`
  Calculate the text length required for the given number of bind variables including dollars.
  `SqlCommand`
  `getCommand()`
  `String`
  `toString(@Nullable ParameterList parameters)`
  Returns string representation of the query, substituting particular parameter values for parameter placeholders.
  `String`
  `toString(@Nullable ParameterList parameters, SqlSerializationContext context)`
  Returns string representation of the query, substituting particular parameter values for parameter placeholders.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### nativeSql

    public final String nativeSql

  - ### bindPositions

    public final int[] bindPositions

  - ### command

    public final SqlCommand command

  - ### multiStatement

    public final boolean multiStatement

- ## Constructor Details

  - ### NativeQuery

    public NativeQuery(String nativeSql, SqlCommand dml)

  - ### NativeQuery

    public NativeQuery(String nativeSql, int @Nullable [] bindPositions, boolean multiStatement, SqlCommand dml)

- ## Method Details

  - ### toString

    public String toString(@Nullable ParameterList parameters)
    Returns string representation of the query, substituting particular parameter values for parameter placeholders.
    Parameters:
      `parameters` - a ParameterList returned by this Query's `Query.createParameterList()` method, or `null` to leave the parameter placeholders unsubstituted.
    Returns:
      a human-readable representation of this query

  - ### toString

    public String toString(@Nullable ParameterList parameters, SqlSerializationContext context)
    Returns string representation of the query, substituting particular parameter values for parameter placeholders.
    Parameters:
      `parameters` - a ParameterList returned by this Query's `Query.createParameterList()` method, or `null` to leave the parameter placeholders unsubstituted.
      `context` - specifies configuration for converting the parameters to string
    Returns:
      a human-readable representation of this query

  - ### bindName

    public static String bindName(int index)
    Returns $1, $2, etc names of bind variables used by backend.
    Parameters:
      `index` - index of a bind variable
    Returns:
      bind variable name

  - ### appendBindName

    public static StringBuilder appendBindName(StringBuilder sb, int index)

  - ### calculateBindLength

    public static int calculateBindLength(int bindCount)
    Calculate the text length required for the given number of bind variables including dollars. Do this to avoid repeated calls to AbstractStringBuilder.expandCapacity(...) and Arrays.copyOf
    Parameters:
      `bindCount` - total number of parameters in a query
    Returns:
      int total character length for $xyz kind of binds

  - ### getCommand

    public SqlCommand getCommand()