Package org.postgresql.core
Class NativeQuery
- java.lang.Object
-
- org.postgresql.core.NativeQuery
-
public class NativeQuery extends java.lang.ObjectRepresents 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 private static java.lang.String[]BIND_NAMESint[]bindPositionsSqlCommandcommandbooleanmultiStatementjava.lang.StringnativeSqlprivate static int[]NO_BINDS
-
Constructor Summary
Constructors Constructor Description NativeQuery(java.lang.String nativeSql, int[] bindPositions, boolean multiStatement, SqlCommand dml)NativeQuery(java.lang.String nativeSql, SqlCommand dml)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.lang.StringBuilderappendBindName(java.lang.StringBuilder sb, int index)static java.lang.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.SqlCommandgetCommand()java.lang.StringtoString(ParameterList parameters)Stringize this query to a human-readable form, substituting particular parameter values for parameter placeholders.
-
-
-
Field Detail
-
BIND_NAMES
private static final java.lang.String[] BIND_NAMES
-
NO_BINDS
private static final int[] NO_BINDS
-
nativeSql
public final java.lang.String nativeSql
-
bindPositions
public final int[] bindPositions
-
command
public final SqlCommand command
-
multiStatement
public final boolean multiStatement
-
-
Constructor Detail
-
NativeQuery
public NativeQuery(java.lang.String nativeSql, SqlCommand dml)
-
NativeQuery
public NativeQuery(java.lang.String nativeSql, int[] bindPositions, boolean multiStatement, SqlCommand dml)
-
-
Method Detail
-
toString
public java.lang.String toString(ParameterList parameters)
Stringize this query to a human-readable form, 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
-
bindName
public static java.lang.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 java.lang.StringBuilder appendBindName(java.lang.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()
-
-