Class CommonSqlUtils
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final PatternRegex for a line starting with a -- SQL style comment character.static final intThe number of characters to drop from the start of a leading where clause. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic PreparedStatementcreatePreparedStatement(Connection con, String sql, boolean forUpdate) Create aPreparedStatementwith settings appropriate for updating or not.static voidforUpdate(boolean skipLocked, String[] tableNames, StringBuilder buf) Generate SQL FOR UPDATE SKIP LOCKED criteria to support locking.static voidforUpdate(boolean skipLocked, StringBuilder buf) Generate SQL FOR UPDATE SKIP LOCKED criteria to support locking.static intlimitOffset(net.solarnetwork.dao.PaginationCriteria filter, StringBuilder buf) Generate SQL LIMIT x OFFSET y criteria to support pagination.static voidlimitOffsetLiteral(net.solarnetwork.dao.PaginationCriteria filter, StringBuilder buf) Generate SQL LIMIT x OFFSET y criteria to support pagination where the limit and offset are generated as literal values.static intorderBySorts(Iterable<net.solarnetwork.domain.SortDescriptor> sorts, Map<String, String> sortKeyMapping, StringBuilder buf) Generate SQL ORDER BY criteria for a set ofSortDescriptor.static intprepareArrayParameter(Connection con, PreparedStatement stmt, int parameterOffset, Integer[] value) Prepare a SQL statementINTEGERarray parameter.static intprepareArrayParameter(Connection con, PreparedStatement stmt, int parameterOffset, Integer[] value, boolean setNull) Prepare a SQL statementINTEGERarray parameter.static intprepareArrayParameter(Connection con, PreparedStatement stmt, int parameterOffset, Long[] value) Prepare a SQL statementBIGINTarray parameter.static intprepareArrayParameter(Connection con, PreparedStatement stmt, int parameterOffset, Long[] value, boolean setNull) Prepare a SQL statementBIGINTarray parameter.static intprepareArrayParameter(Connection con, PreparedStatement stmt, int parameterOffset, String[] value) Prepare a SQL statementTEXTarray parameter.static intprepareArrayParameter(Connection con, PreparedStatement stmt, int parameterOffset, String[] value, boolean setNull) Prepare a SQL statementTEXTarray parameter.static intprepareArrayParameter(Connection con, PreparedStatement stmt, int parameterOffset, String arrayType, Object[] value) Prepare a SQL statement array parameter.static intprepareArrayParameter(Connection con, PreparedStatement stmt, int parameterOffset, String arrayType, Object[] value, boolean setNull) Prepare a SQL statement array parameter.static intprepareArrayParameter(Connection con, PreparedStatement stmt, int parameterOffset, UUID[] value) Prepare a SQL statementUUIDarray parameter.static intprepareArrayParameter(Connection con, PreparedStatement stmt, int parameterOffset, UUID[] value, boolean setNull) Prepare a SQL statementUUIDarray parameter.static intprepareCodedValue(PreparedStatement stmt, int parameterOffset, net.solarnetwork.domain.CodedValue value, net.solarnetwork.domain.CodedValue defaultValue, boolean setNull) Prepare a SQL queryCodedValueparameter as aINTEGER.static intprepareCodedValueChar(PreparedStatement stmt, int parameterOffset, net.solarnetwork.domain.CodedValue value, net.solarnetwork.domain.CodedValue defaultValue, boolean setNull) Prepare a SQL queryCodedValueparameter as aCHARACTER.static intprepareCodedValuesArray(Connection con, PreparedStatement stmt, int parameterOffset, Collection<? extends net.solarnetwork.domain.CodedValue> values, boolean setNull) Prepare a SQL queryCodedValueparameter as aINTEGER.static intprepareDateRange(net.solarnetwork.dao.DateRangeCriteria filter, PreparedStatement stmt, int parameterOffset) Prepare a SQL query date range filter.static intprepareJsonString(Object data, PreparedStatement stmt, int parameterOffset, boolean setNull) Prepare a SQL query JSON string parameter.static intprepareLimitOffset(net.solarnetwork.dao.PaginationCriteria filter, Connection con, PreparedStatement stmt, int parameterOffset) Prepare a SQL query limit/offset.static intprepareOptimizedArrayParameter(Connection con, PreparedStatement stmt, int parameterOffset, Integer[] value) Prepare a SQL statementINTEGERarray parameter, optimized to a non-array parameter if the array holds a single object.static intprepareOptimizedArrayParameter(Connection con, PreparedStatement stmt, int parameterOffset, Long[] value) Prepare a SQL statementBIGINTarray parameter, optimized to a non-array parameter if the array holds a single object.static intprepareOptimizedArrayParameter(Connection con, PreparedStatement stmt, int parameterOffset, Long[] value, boolean setNull) Prepare a SQL statementBIGINTarray parameter, optimized to a non-array parameter if the array holds a single object.static intprepareOptimizedArrayParameter(Connection con, PreparedStatement stmt, int parameterOffset, String[] value) Prepare a SQL statementTEXTarray parameter, optimized to a non-array parameter if the array holds a single object.static intprepareOptimizedArrayParameter(Connection con, PreparedStatement stmt, int parameterOffset, String[] value, boolean setNull) Prepare a SQL statementTEXTarray parameter, optimized to a non-array parameter if the array holds a single object.static intprepareOptimizedArrayParameter(Connection con, PreparedStatement stmt, int parameterOffset, String arrayType, Object[] value) Prepare a SQL statement array parameter, optimized to a non-array parameter if the array holds a single object.static intprepareOptimizedArrayParameter(Connection con, PreparedStatement stmt, int parameterOffset, String arrayType, Object[] value, boolean setNull) Prepare a SQL statement array parameter, optimized to a non-array parameter if the array holds a single object.static intprepareOptimizedArrayParameter(Connection con, PreparedStatement stmt, int parameterOffset, UUID[] value) Prepare a SQL statementUUIDarray parameter, optimized to a non-array parameter if the array holds a single object.static intprepareOptimizedArrayParameter(Connection con, PreparedStatement stmt, int parameterOffset, UUID[] value, boolean setNull) Prepare a SQL statementUUIDarray parameter, optimized to a non-array parameter if the array holds a single object.static intwhereArrayColContains(Object[] array, String colName, StringBuilder buf) Generate SQL WHERE criteria for an array column containment clause.static intwhereDateRange(net.solarnetwork.dao.DateRangeCriteria filter, String colName, StringBuilder buf) Generate SQL WHERE criteria for a date range.static intwhereOptimizedArrayContains(Object[] array, String colName, StringBuilder buf) Generate SQL WHERE criteria for an array containment clause.static StringwrappedCountQuery(String sql) Wrap a SQL query with a SELECT COUNT(*) clause.
-
Field Details
-
SQL_COMMENT
Regex for a line starting with a -- SQL style comment character. -
WHERE_COMPONENT_PREFIX_LENGTH
public static final int WHERE_COMPONENT_PREFIX_LENGTHThe number of characters to drop from the start of a leading where clause.- See Also:
-
-
Constructor Details
-
CommonSqlUtils
public CommonSqlUtils()
-
-
Method Details
-
prepareOptimizedArrayParameter
public static int prepareOptimizedArrayParameter(Connection con, PreparedStatement stmt, int parameterOffset, Integer[] value) throws SQLException Prepare a SQL statementINTEGERarray parameter, optimized to a non-array parameter if the array holds a single object.The parameter will not be set if
valueis null.- Parameters:
con- the JDBC connectionstmt- the JDBC statementparameterOffset- the zero-based starting JDBC statement parameter offsetvalue- the array value- Returns:
- the new JDBC statement parameter offset
- Throws:
SQLException- if any SQL error occurs- Since:
- 2.4
-
prepareOptimizedArrayParameter
public static int prepareOptimizedArrayParameter(Connection con, PreparedStatement stmt, int parameterOffset, Long[] value) throws SQLException Prepare a SQL statementBIGINTarray parameter, optimized to a non-array parameter if the array holds a single object.The parameter will not be set if
valueis null.- Parameters:
con- the JDBC connectionstmt- the JDBC statementparameterOffset- the zero-based starting JDBC statement parameter offsetvalue- the array value- Returns:
- the new JDBC statement parameter offset
- Throws:
SQLException- if any SQL error occurs
-
prepareOptimizedArrayParameter
public static int prepareOptimizedArrayParameter(Connection con, PreparedStatement stmt, int parameterOffset, Long[] value, boolean setNull) throws SQLException Prepare a SQL statementBIGINTarray parameter, optimized to a non-array parameter if the array holds a single object.- Parameters:
con- the JDBC connectionstmt- the JDBC statementparameterOffset- the zero-based starting JDBC statement parameter offsetvalue- the array valuesetNull- true to set a NULL parameter ifvalueis null, or false to skip the parameter- Returns:
- the new JDBC statement parameter offset
- Throws:
SQLException- if any SQL error occurs- Since:
- 2.2
-
prepareOptimizedArrayParameter
public static int prepareOptimizedArrayParameter(Connection con, PreparedStatement stmt, int parameterOffset, String[] value) throws SQLException Prepare a SQL statementTEXTarray parameter, optimized to a non-array parameter if the array holds a single object.The parameter will not be set if
valueis null.- Parameters:
con- the JDBC connectionstmt- the JDBC statementparameterOffset- the zero-based starting JDBC statement parameter offsetvalue- the array value- Returns:
- the new JDBC statement parameter offset
- Throws:
SQLException- if any SQL error occurs
-
prepareOptimizedArrayParameter
public static int prepareOptimizedArrayParameter(Connection con, PreparedStatement stmt, int parameterOffset, String[] value, boolean setNull) throws SQLException Prepare a SQL statementTEXTarray parameter, optimized to a non-array parameter if the array holds a single object.- Parameters:
con- the JDBC connectionstmt- the JDBC statementparameterOffset- the zero-based starting JDBC statement parameter offsetvalue- the array valuesetNull- true to set a NULL parameter ifvalueis null, or false to skip the parameter- Returns:
- the new JDBC statement parameter offset
- Throws:
SQLException- if any SQL error occurs- Since:
- 2.2
-
prepareOptimizedArrayParameter
public static int prepareOptimizedArrayParameter(Connection con, PreparedStatement stmt, int parameterOffset, UUID[] value) throws SQLException Prepare a SQL statementUUIDarray parameter, optimized to a non-array parameter if the array holds a single object.The parameter will not be set if
valueis null.- Parameters:
con- the JDBC connectionstmt- the JDBC statementparameterOffset- the zero-based starting JDBC statement parameter offsetvalue- the array value- Returns:
- the new JDBC statement parameter offset
- Throws:
SQLException- if any SQL error occurs- Since:
- 2.6
-
prepareOptimizedArrayParameter
public static int prepareOptimizedArrayParameter(Connection con, PreparedStatement stmt, int parameterOffset, UUID[] value, boolean setNull) throws SQLException Prepare a SQL statementUUIDarray parameter, optimized to a non-array parameter if the array holds a single object.- Parameters:
con- the JDBC connectionstmt- the JDBC statementparameterOffset- the zero-based starting JDBC statement parameter offsetvalue- the array valuesetNull- true to set a NULL parameter ifvalueis null, or false to skip the parameter- Returns:
- the new JDBC statement parameter offset
- Throws:
SQLException- if any SQL error occurs- Since:
- 2.6
-
prepareOptimizedArrayParameter
public static int prepareOptimizedArrayParameter(Connection con, PreparedStatement stmt, int parameterOffset, String arrayType, Object[] value) throws SQLException Prepare a SQL statement array parameter, optimized to a non-array parameter if the array holds a single object.The parameter will not be set if
valueis null.- Parameters:
con- the JDBC connectionstmt- the JDBC statementparameterOffset- the zero-based starting JDBC statement parameter offsetarrayType- the SQL array type to usevalue- the array value- Returns:
- the new JDBC statement parameter offset
- Throws:
SQLException- if any SQL error occurs
-
prepareOptimizedArrayParameter
public static int prepareOptimizedArrayParameter(Connection con, PreparedStatement stmt, int parameterOffset, String arrayType, Object[] value, boolean setNull) throws SQLException Prepare a SQL statement array parameter, optimized to a non-array parameter if the array holds a single object.- Parameters:
con- the JDBC connectionstmt- the JDBC statementparameterOffset- the zero-based starting JDBC statement parameter offsetarrayType- the SQL array type to usevalue- the array valuesetNull- true to set a NULL parameter ifvalueis null, or false to skip the parameter- Returns:
- the new JDBC statement parameter offset
- Throws:
SQLException- if any SQL error occurs- Since:
- 2.2
-
prepareArrayParameter
public static int prepareArrayParameter(Connection con, PreparedStatement stmt, int parameterOffset, Integer[] value) throws SQLException Prepare a SQL statementINTEGERarray parameter.The parameter will not be set if
valueis null.- Parameters:
con- the JDBC connectionstmt- the JDBC statementparameterOffset- the zero-based starting JDBC statement parameter offsetvalue- the array value- Returns:
- the new JDBC statement parameter offset
- Throws:
SQLException- if any SQL error occurs- Since:
- 2.1
-
prepareArrayParameter
public static int prepareArrayParameter(Connection con, PreparedStatement stmt, int parameterOffset, Integer[] value, boolean setNull) throws SQLException Prepare a SQL statementINTEGERarray parameter.- Parameters:
con- the JDBC connectionstmt- the JDBC statementparameterOffset- the zero-based starting JDBC statement parameter offsetvalue- the array valuesetNull- true to set a NULL parameter ifvalueis null, or false to skip the parameter- Returns:
- the new JDBC statement parameter offset
- Throws:
SQLException- if any SQL error occurs- Since:
- 2.2
-
prepareArrayParameter
public static int prepareArrayParameter(Connection con, PreparedStatement stmt, int parameterOffset, Long[] value) throws SQLException Prepare a SQL statementBIGINTarray parameter.The parameter will not be set if
valueis null.- Parameters:
con- the JDBC connectionstmt- the JDBC statementparameterOffset- the zero-based starting JDBC statement parameter offsetvalue- the array value- Returns:
- the new JDBC statement parameter offset
- Throws:
SQLException- if any SQL error occurs- Since:
- 2.1
-
prepareArrayParameter
public static int prepareArrayParameter(Connection con, PreparedStatement stmt, int parameterOffset, Long[] value, boolean setNull) throws SQLException Prepare a SQL statementBIGINTarray parameter.- Parameters:
con- the JDBC connectionstmt- the JDBC statementparameterOffset- the zero-based starting JDBC statement parameter offsetvalue- the array valuesetNull- true to set a NULL parameter ifvalueis null, or false to skip the parameter- Returns:
- the new JDBC statement parameter offset
- Throws:
SQLException- if any SQL error occurs- Since:
- 2.2
-
prepareArrayParameter
public static int prepareArrayParameter(Connection con, PreparedStatement stmt, int parameterOffset, String[] value) throws SQLException Prepare a SQL statementTEXTarray parameter.The parameter will not be set if
valueis null.- Parameters:
con- the JDBC connectionstmt- the JDBC statementparameterOffset- the zero-based starting JDBC statement parameter offsetvalue- the array value- Returns:
- the new JDBC statement parameter offset
- Throws:
SQLException- if any SQL error occurs- Since:
- 2.1
-
prepareArrayParameter
public static int prepareArrayParameter(Connection con, PreparedStatement stmt, int parameterOffset, String[] value, boolean setNull) throws SQLException Prepare a SQL statementTEXTarray parameter.- Parameters:
con- the JDBC connectionstmt- the JDBC statementparameterOffset- the zero-based starting JDBC statement parameter offsetvalue- the array valuesetNull- true to set a NULL parameter ifvalueis null, or false to skip the parameter- Returns:
- the new JDBC statement parameter offset
- Throws:
SQLException- if any SQL error occurs- Since:
- 2.2
-
prepareArrayParameter
public static int prepareArrayParameter(Connection con, PreparedStatement stmt, int parameterOffset, UUID[] value) throws SQLException Prepare a SQL statementUUIDarray parameter.The parameter will not be set if
valueis null.- Parameters:
con- the JDBC connectionstmt- the JDBC statementparameterOffset- the zero-based starting JDBC statement parameter offsetvalue- the array value- Returns:
- the new JDBC statement parameter offset
- Throws:
SQLException- if any SQL error occurs- Since:
- 2.6
-
prepareArrayParameter
public static int prepareArrayParameter(Connection con, PreparedStatement stmt, int parameterOffset, UUID[] value, boolean setNull) throws SQLException Prepare a SQL statementUUIDarray parameter.- Parameters:
con- the JDBC connectionstmt- the JDBC statementparameterOffset- the zero-based starting JDBC statement parameter offsetvalue- the array valuesetNull- true to set a NULL parameter ifvalueis null, or false to skip the parameter- Returns:
- the new JDBC statement parameter offset
- Throws:
SQLException- if any SQL error occurs- Since:
- 2.6
-
prepareArrayParameter
public static int prepareArrayParameter(Connection con, PreparedStatement stmt, int parameterOffset, String arrayType, Object[] value) throws SQLException Prepare a SQL statement array parameter.The parameter will not be set if
valueis null.- Parameters:
con- the JDBC connectionstmt- the JDBC statementparameterOffset- the zero-based starting JDBC statement parameter offsetarrayType- the SQL array type to usevalue- the array value- Returns:
- the new JDBC statement parameter offset
- Throws:
SQLException- if any SQL error occurs- Since:
- 2.1
-
prepareArrayParameter
public static int prepareArrayParameter(Connection con, PreparedStatement stmt, int parameterOffset, String arrayType, Object[] value, boolean setNull) throws SQLException Prepare a SQL statement array parameter.- Parameters:
con- the JDBC connectionstmt- the JDBC statementparameterOffset- the zero-based starting JDBC statement parameter offsetarrayType- the SQL array type to usevalue- the array valuesetNull- true to set a NULL parameter ifvalueis null, or false to skip the parameter- Returns:
- the new JDBC statement parameter offset
- Throws:
SQLException- if any SQL error occurs- Since:
- 2.2
-
forUpdate
Generate SQL FOR UPDATE SKIP LOCKED criteria to support locking.- Parameters:
skipLocked- true to include the SKIP LOCKED clausebuf- the buffer to append the SQL to
-
forUpdate
Generate SQL FOR UPDATE SKIP LOCKED criteria to support locking.- Parameters:
skipLocked- true to include the SKIP LOCKED clausetableNames- explicit table names to lock, or null for default (all referenced tables)buf- the buffer to append the SQL to- Since:
- 2.2
-
limitOffset
Generate SQL LIMIT x OFFSET y criteria to support pagination.The buffer is populated with a pattern of \nLIMIT ? OFFSET ?.
- Parameters:
filter- the search criteriabuf- the buffer to append the SQL to- Returns:
- the number of JDBC query parameters generated
-
prepareLimitOffset
public static int prepareLimitOffset(net.solarnetwork.dao.PaginationCriteria filter, Connection con, PreparedStatement stmt, int parameterOffset) throws SQLException Prepare a SQL query limit/offset.- Parameters:
filter- the search criteriacon- the JDBC connectionstmt- the JDBC statementparameterOffset- the zero-based starting JDBC statement parameter offset- Returns:
- the new JDBC statement parameter offset
- Throws:
SQLException- if any SQL error occurs- Since:
- 2.1
- See Also:
-
wrappedCountQuery
Wrap a SQL query with a SELECT COUNT(*) clause.- Parameters:
sql- the SQL query to wrap- Returns:
- the wrapped query
- Since:
- 2.1
-
limitOffsetLiteral
public static void limitOffsetLiteral(net.solarnetwork.dao.PaginationCriteria filter, StringBuilder buf) Generate SQL LIMIT x OFFSET y criteria to support pagination where the limit and offset are generated as literal values.The buffer is populated with a pattern of \nLIMIT x OFFSET y.
- Parameters:
filter- the search criteriabuf- the buffer to append the SQL to
-
createPreparedStatement
public static PreparedStatement createPreparedStatement(Connection con, String sql, boolean forUpdate) throws SQLException Create aPreparedStatementwith settings appropriate for updating or not.- Parameters:
con- the connectionsql- the SQL statementforUpdate- true to use a scroll-insensitive, updatable, or false for a forward-only, read-only oneinvalid reference
ResetSet- Returns:
- the prepared statement
- Throws:
SQLException- if any SQL error occurs
-
whereArrayColContains
Generate SQL WHERE criteria for an array column containment clause.- Parameters:
array- the array value to matchcolName- the array SQL column namebuf- the buffer to append the SQL to- Returns:
- the number of JDBC query parameters generated
- Since:
- 2.7
- See Also:
-
whereOptimizedArrayContains
Generate SQL WHERE criteria for an array containment clause.If
arraycontains exactly one value, the generated SQL will use a simple equality comparison. Otherwise anANY()comparison will be generated.- Parameters:
array- the array value to matchcolName- the array SQL column namebuf- the buffer to append the SQL to- Returns:
- the number of JDBC query parameters generated
- Since:
- 2.1
- See Also:
-
whereDateRange
public static int whereDateRange(net.solarnetwork.dao.DateRangeCriteria filter, String colName, StringBuilder buf) Generate SQL WHERE criteria for a date range.The buffer is populated with a pattern of \tAND c = ?\n for each clause. The leading tab and AND and space characters are not stripped.
- Parameters:
filter- the search criteriabuf- the buffer to append the SQL tocolumn- the date column name to use, e.g.solardatum.ts- Returns:
- the number of JDBC query parameters generated
- Since:
- 2.1
-
prepareDateRange
public static int prepareDateRange(net.solarnetwork.dao.DateRangeCriteria filter, PreparedStatement stmt, int parameterOffset) throws SQLException Prepare a SQL query date range filter.- Parameters:
filter- the search criteriastmt- the JDBC statementparameterOffset- the zero-based starting JDBC statement parameter offset- Returns:
- the new JDBC statement parameter offset
- Throws:
SQLException- if any SQL error occurs- Since:
- 2.1
-
prepareJsonString
public static int prepareJsonString(Object data, PreparedStatement stmt, int parameterOffset, boolean setNull) throws SQLException Prepare a SQL query JSON string parameter.- Parameters:
data- the JSON data; will be serialized viaJsonUtils.getJSONString(Object, String)stmt- the JDBC statementparameterOffset- the zero-based starting JDBC statement parameter offsetsetNull- true to set a NULL parameter ifdataserializes to null, or false to skip the parameter- Returns:
- the new JDBC statement parameter offset
- Throws:
SQLException- if any SQL error occurs- Since:
- 2.2
-
prepareCodedValue
public static int prepareCodedValue(PreparedStatement stmt, int parameterOffset, net.solarnetwork.domain.CodedValue value, net.solarnetwork.domain.CodedValue defaultValue, boolean setNull) throws SQLException Prepare a SQL queryCodedValueparameter as aINTEGER.- Parameters:
stmt- the JDBC statementparameterOffset- the zero-based starting JDBC statement parameter offsetvalue- the value to setdefaultValue- the value to set ifvalueis nullsetNull- true to set a NULL parameter ifvalueis null and defaultValue is null, or false to skip the parameter- Returns:
- the new JDBC statement parameter offset
- Throws:
SQLException- if any SQL error occurs
-
prepareCodedValueChar
public static int prepareCodedValueChar(PreparedStatement stmt, int parameterOffset, net.solarnetwork.domain.CodedValue value, net.solarnetwork.domain.CodedValue defaultValue, boolean setNull) throws SQLException Prepare a SQL queryCodedValueparameter as aCHARACTER.- Parameters:
stmt- the JDBC statementparameterOffset- the zero-based starting JDBC statement parameter offsetvalue- the value to setdefaultValue- the value to set ifvalueis nullsetNull- true to set a NULL parameter ifvalueis null and defaultValue is null, or false to skip the parameter- Returns:
- the new JDBC statement parameter offset
- Throws:
SQLException- if any SQL error occurs- Since:
- 2.5
-
prepareCodedValuesArray
public static int prepareCodedValuesArray(Connection con, PreparedStatement stmt, int parameterOffset, Collection<? extends net.solarnetwork.domain.CodedValue> values, boolean setNull) throws SQLException Prepare a SQL queryCodedValueparameter as aINTEGER.- Parameters:
stmt- the JDBC statementparameterOffset- the zero-based starting JDBC statement parameter offsetsetNull- true to set a NULL parameter ifvalueis null and defaultValue is null, or false to skip the parametervalue- the value to setdefaultValue- the value to set ifvalueis null- Returns:
- the new JDBC statement parameter offset
- Throws:
SQLException- if any SQL error occurs- Since:
- 2.2
-
orderBySorts
public static int orderBySorts(Iterable<net.solarnetwork.domain.SortDescriptor> sorts, Map<String, String> sortKeyMapping, StringBuilder buf) Generate SQL ORDER BY criteria for a set ofSortDescriptor.The buffer is populated with a pattern of , key for each key. The leading comma and space characters are not stripped, but the returned value indicates the number of characters to trim from the results if needed.
- Parameters:
sorts- the sortssortKeyMapping- the mapping of sort keys to SQL sort namesbuf- the buffer to append the SQL to- Returns:
- the number of leading "joining" characters added to
buf; will either be 0 or 2 - Since:
- 2.3
-