Class NativeQuery
java.lang.Object
org.postgresql.core.NativeQuery
Represents a query that is ready for execution by backend. The main difference from JDBC is ? are
replaced with $1, $2, etc.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final String[]final int[]final SqlCommandfinal booleanfinal Stringprivate static final int[]private final boolean -
Constructor Summary
ConstructorsConstructorDescriptionNativeQuery(String nativeSql, int[] bindPositions, boolean multiStatement, SqlCommand dml) NativeQuery(String nativeSql, int[] bindPositions, boolean multiStatement, SqlCommand dml, boolean standardConformingStrings) NativeQuery(String nativeSql, SqlCommand dml) -
Method Summary
Modifier and TypeMethodDescriptionstatic StringBuilderappendBindName(StringBuilder sb, int index) static StringbindName(int index) Returns $1, $2, etc names of bind variables used by backend.static intcalculateBindLength(int bindCount) Calculate the text length required for the given number of bind variables including dollars.booleanisParsedFor(boolean standardConformingStrings) Returns true if a parse with the given value ofstandard_conforming_stringsgives the same string literals, and so the same placeholders, as the parse of this query.toString(ParameterList parameters) Returns string representation of the query, substituting particular parameter values for parameter placeholders.toString(ParameterList parameters, SqlSerializationContext context) Returns string representation of the query, substituting particular parameter values for parameter placeholders.
-
Field Details
-
BIND_NAMES
-
NO_BINDS
private static final int[] NO_BINDS -
nativeSql
-
bindPositions
public final int[] bindPositions -
command
-
multiStatement
public final boolean multiStatement -
standardConformingStrings
private final boolean standardConformingStrings
-
-
Constructor Details
-
NativeQuery
-
NativeQuery
-
NativeQuery
public NativeQuery(String nativeSql, int[] bindPositions, boolean multiStatement, SqlCommand dml, boolean standardConformingStrings)
-
-
Method Details
-
isParsedFor
public boolean isParsedFor(boolean standardConformingStrings) Returns true if a parse with the given value ofstandard_conforming_stringsgives the same string literals, and so the same placeholders, as the parse of this query. The setting only changes the meaning of a backslash.- Parameters:
standardConformingStrings- the current value ofstandard_conforming_strings- Returns:
- true if parameter values can be put in place of the placeholders
-
toString
Returns string representation of the query, substituting particular parameter values for parameter placeholders.- Parameters:
parameters- a ParameterList returned by this Query'sQuery.createParameterList()method, ornullto leave the parameter placeholders unsubstituted.- Returns:
- a human-readable representation of this query
-
toString
Returns string representation of the query, substituting particular parameter values for parameter placeholders.- Parameters:
parameters- a ParameterList returned by this Query'sQuery.createParameterList()method, ornullto leave the parameter placeholders unsubstituted.context- specifies configuration for converting the parameters to string- Returns:
- a human-readable representation of this query
-
bindName
Returns $1, $2, etc names of bind variables used by backend.- Parameters:
index- index of a bind variable- Returns:
- bind variable name
-
appendBindName
-
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
-