Class Parameters
- Since:
- 3.0.0
- Author:
- Mark Allen
-
Method Summary
Modifier and TypeMethodDescriptionstatic @NonNull TypedParameterAcquires a parameter of array type, preserving element type information so it is accessible at runtime.static <E> @NonNull TypedParameterAcquires a parameter of array type, preserving element type information so it is accessible at runtime.static @NonNull InListParameterAcquires a parameter for SQLINlist expansion using aboolean[]array.static @NonNull InListParameterAcquires a parameter for SQLINlist expansion using abyte[]array.static @NonNull InListParameterAcquires a parameter for SQLINlist expansion using achar[]array.static @NonNull InListParameterAcquires a parameter for SQLINlist expansion using adouble[]array.static @NonNull InListParameterAcquires a parameter for SQLINlist expansion using afloat[]array.static @NonNull InListParameterAcquires a parameter for SQLINlist expansion using anint[]array.static @NonNull InListParameterAcquires a parameter for SQLINlist expansion using along[]array.static @NonNull InListParameterAcquires a parameter for SQLINlist expansion using ashort[]array.static <E> @NonNull InListParameterAcquires a parameter for SQLINlist expansion using a Java array.static <E> @NonNull InListParameterinList(@NonNull Collection<@Nullable E> elements) Acquires a parameter for SQLINlist expansion using aCollection.static @NonNull JsonParameterAcquires a JSON parameter for "stringified" JSON, usingJsonParameter.BindingPreference.BINARY.static @NonNull JsonParameterjson(@Nullable String json, @NonNull JsonParameter.BindingPreference bindingPreference) Acquires a JSON parameter for "stringified" JSON.static <E> @NonNull TypedParameterAcquires a parameter of typeList, preserving type information so it is accessible at runtime.static <K,V> @NonNull TypedParameter Acquires a parameter of typeMap, preserving key and value type information so they are accessible at runtime.static <E> @NonNull TypedParameterAcquires a parameter of typeSet, preserving type information so it is accessible at runtime.static <E> @NonNull SqlArrayParameter<E> sqlArrayOf(@NonNull String baseTypeName, E @Nullable [] array) Acquires a SQL ARRAY parameter for a native Java array given an appropriatejava.sql.Array#getBaseTypeName().static <E> @NonNull SqlArrayParameter<E> sqlArrayOf(@NonNull String baseTypeName, @Nullable List<E> list) Acquires a SQL ARRAY parameter for aListgiven an appropriatejava.sql.Array#getBaseTypeName().static @NonNull VectorParametervectorOfBigDecimals(@Nullable List<@NonNull BigDecimal> elements) Acquires a vector parameter for aListofBigDecimal.static @NonNull VectorParametervectorOfDoubles(double @Nullable [] elements) Acquires a vector parameter for an array ofdouble.static @NonNull VectorParametervectorOfDoubles(@Nullable List<@NonNull Double> elements) static @NonNull VectorParametervectorOfFloats(float @Nullable [] elements) Acquires a vector parameter for an array offloat.static @NonNull VectorParametervectorOfFloats(@Nullable List<@NonNull Float> elements)
-
Method Details
-
sqlArrayOf
public static <E> @NonNull SqlArrayParameter<E> sqlArrayOf(@NonNull String baseTypeName, @Nullable List<E> list) Acquires a SQL ARRAY parameter for aListgiven an appropriatejava.sql.Array#getBaseTypeName().You may determine available
baseTypeNamevalues for your database by examining metadata exposed viaDatabase.readDatabaseMetaData(DatabaseMetaDataReader).For non-SQL array binding where you need to preserve the Java element type for custom binders, use
arrayOf(Class, Object)instead.- Type Parameters:
E- the element type of the Java list (List<E>); each element must be bindable tobaseTypeNameby the activePreparedStatementBinder.- Parameters:
baseTypeName- the SQL ARRAY element type, e.g."text","uuid","float4","float8"...list- the list whose elements will be used to populate the SQL ARRAY- Returns:
- a SQL ARRAY parameter for the given list
-
sqlArrayOf
public static <E> @NonNull SqlArrayParameter<E> sqlArrayOf(@NonNull String baseTypeName, E @Nullable [] array) Acquires a SQL ARRAY parameter for a native Java array given an appropriatejava.sql.Array#getBaseTypeName().You may determine available
baseTypeNamevalues for your database by examining metadata exposed viaDatabase.readDatabaseMetaData(DatabaseMetaDataReader).For non-SQL array binding where you need to preserve the Java element type for custom binders, use
arrayOf(Class, Object)instead.- Type Parameters:
E- the element type of the Java array (T[]); each element must be bindable tobaseTypeNameby the activePreparedStatementBinder.- Parameters:
baseTypeName- the SQL ARRAY element type, e.g."text","uuid","float4","float8"...array- the native Java array whose elements will be used to populate the SQL ARRAY- Returns:
- a SQL ARRAY parameter for the given Java array
-
inList
Acquires a parameter for SQLINlist expansion using aCollection. Elements must be non-empty.- Type Parameters:
E- the element type- Parameters:
elements- the elements to expand into SQLINlist placeholders- Returns:
- an IN-list parameter for the given elements
-
inList
Acquires a parameter for SQLINlist expansion using a Java array. Elements must be non-empty.- Type Parameters:
E- the element type- Parameters:
elements- the elements to expand into SQLINlist placeholders- Returns:
- an IN-list parameter for the given elements
-
inList
Acquires a parameter for SQLINlist expansion using abyte[]array. Elements must be non-empty.- Parameters:
elements- the elements to expand into SQLINlist placeholders- Returns:
- an IN-list parameter for the given elements
-
inList
Acquires a parameter for SQLINlist expansion using ashort[]array. Elements must be non-empty.- Parameters:
elements- the elements to expand into SQLINlist placeholders- Returns:
- an IN-list parameter for the given elements
-
inList
Acquires a parameter for SQLINlist expansion using anint[]array. Elements must be non-empty.- Parameters:
elements- the elements to expand into SQLINlist placeholders- Returns:
- an IN-list parameter for the given elements
-
inList
Acquires a parameter for SQLINlist expansion using along[]array. Elements must be non-empty.- Parameters:
elements- the elements to expand into SQLINlist placeholders- Returns:
- an IN-list parameter for the given elements
-
inList
Acquires a parameter for SQLINlist expansion using afloat[]array. Elements must be non-empty.- Parameters:
elements- the elements to expand into SQLINlist placeholders- Returns:
- an IN-list parameter for the given elements
-
inList
Acquires a parameter for SQLINlist expansion using adouble[]array. Elements must be non-empty.- Parameters:
elements- the elements to expand into SQLINlist placeholders- Returns:
- an IN-list parameter for the given elements
-
inList
Acquires a parameter for SQLINlist expansion using aboolean[]array. Elements must be non-empty.- Parameters:
elements- the elements to expand into SQLINlist placeholders- Returns:
- an IN-list parameter for the given elements
-
inList
Acquires a parameter for SQLINlist expansion using achar[]array. Elements must be non-empty.- Parameters:
elements- the elements to expand into SQLINlist placeholders- Returns:
- an IN-list parameter for the given elements
-
arrayOf
public static <E> @NonNull TypedParameter arrayOf(@NonNull Class<E> elementType, E @Nullable [] array) Acquires a parameter of array type, preserving element type information so it is accessible at runtime.This is useful when you want to bind an array via a
CustomParameterBinderand need the component type to be preserved forTargetTypematching.For SQL
ARRAYbinding, usesqlArrayOf(String, Object[])instead. If you need a formal SQLARRAYparameter for JDBC array binding, do not use this method.Note: this kind of parameter requires a corresponding
CustomParameterBinderto be registered, even when the wrapped value isnull; implementCustomParameterBinder.bindNull(StatementContext, PreparedStatement, Integer, TargetType, Integer)if you want typed nulls to bind successfully.- Type Parameters:
E- the element type of the array- Parameters:
elementType- the element type of the arrayarray- the array value to wrap; may benull- Returns:
- a
TypedParameterrepresenting aE[]suitable for use with custom binders
-
arrayOf
public static @NonNull TypedParameter arrayOf(@NonNull Class<?> elementType, @Nullable Object array) Acquires a parameter of array type, preserving element type information so it is accessible at runtime.This overload supports primitive arrays by passing the primitive component class (for example,
int.class) and the corresponding primitive array.For SQL
ARRAYbinding, usesqlArrayOf(String, Object[])instead. If you need a formal SQLARRAYparameter for JDBC array binding, do not use this method.Note: this kind of parameter requires a corresponding
CustomParameterBinderto be registered, even when the wrapped value isnull; implementCustomParameterBinder.bindNull(StatementContext, PreparedStatement, Integer, TargetType, Integer)if you want typed nulls to bind successfully.- Parameters:
elementType- the element type of the array (may be primitive)array- the array value to wrap; may benull- Returns:
- a
TypedParameterrepresenting an array suitable for use with custom binders
-
vectorOfDoubles
Acquires a vector parameter for an array ofdouble.- Parameters:
elements- the elements of the vector parameter- Returns:
- the vector parameter
-
vectorOfDoubles
- Parameters:
elements- the elements of the vector parameter- Returns:
- the vector parameter
-
vectorOfFloats
Acquires a vector parameter for an array offloat.- Parameters:
elements- the elements of the vector parameter- Returns:
- the vector parameter
-
vectorOfFloats
- Parameters:
elements- the elements of the vector parameter- Returns:
- the vector parameter
-
vectorOfBigDecimals
public static @NonNull VectorParameter vectorOfBigDecimals(@Nullable List<@NonNull BigDecimal> elements) Acquires a vector parameter for aListofBigDecimal.- Parameters:
elements- the elements of the vector parameter- Returns:
- the vector parameter
-
json
Acquires a JSON parameter for "stringified" JSON, usingJsonParameter.BindingPreference.BINARY.- Parameters:
json- the stringified JSON for this parameter- Returns:
- the JSON parameter
-
json
public static @NonNull JsonParameter json(@Nullable String json, @NonNull JsonParameter.BindingPreference bindingPreference) Acquires a JSON parameter for "stringified" JSON.- Parameters:
json- the stringified JSON for this parameterbindingPreference- how the JSON parameter should be bound to aPreparedStatement- Returns:
- the JSON parameter
-
listOf
public static <E> @NonNull TypedParameter listOf(@NonNull Class<E> elementType, @Nullable List<E> list) Acquires a parameter of typeList, preserving type information so it is accessible at runtime.This is useful when you want to bind a parameterized collection such as
List<UUID>orList<String>and need the generic type argument (e.g.UUID.class) to be preserved.The resulting
TypedParametercarries both the runtime value and its generic type so thatCustomParameterBinder.appliesTo(TargetType)can match against the element type.Note: this kind of parameter requires a corresponding
CustomParameterBinderto be registered, even when the wrapped value isnull; implementCustomParameterBinder.bindNull(StatementContext, PreparedStatement, Integer, TargetType, Integer)if you want typed nulls to bind successfully.- Type Parameters:
E- the element type of the list- Parameters:
elementType- theClassrepresenting the type of elements contained in the list; used to preserve generic type informationlist- the list value to wrap; may benull- Returns:
- a
TypedParameterrepresenting aList<E>suitable for use with custom binders
-
setOf
public static <E> @NonNull TypedParameter setOf(@NonNull Class<E> elementType, @Nullable Set<E> set) Acquires a parameter of typeSet, preserving type information so it is accessible at runtime.This is useful when you want to bind a parameterized collection such as
Set<UUID>orSet<String>and need the generic type argument (e.g.UUID.class) to be preserved.The resulting
TypedParametercarries both the runtime value and its generic type so thatCustomParameterBinder.appliesTo(TargetType)can match against the element type.Note: this kind of parameter requires a corresponding
CustomParameterBinderto be registered, even when the wrapped value isnull; implementCustomParameterBinder.bindNull(StatementContext, PreparedStatement, Integer, TargetType, Integer)if you want typed nulls to bind successfully.- Type Parameters:
E- the element type of the set- Parameters:
elementType- theClassrepresenting the type of elements contained in the set; used to preserve generic type informationset- the set value to wrap; may benull- Returns:
- a
TypedParameterrepresenting aSet<E>suitable for use with custom binders
-
mapOf
public static <K,V> @NonNull TypedParameter mapOf(@NonNull Class<K> keyType, @NonNull Class<V> valueType, @Nullable Map<K, V> map) Acquires a parameter of typeMap, preserving key and value type information so they are accessible at runtime.This is useful when you want to bind a parameterized collection such as
Map<UUID, Integer>and need the generic type arguments (e.g.UUID.classandInteger.class) to be preserved.The resulting
TypedParametercarries both the runtime value and its generic type so thatCustomParameterBinder.appliesTo(TargetType)can match against the element type.Note: this kind of parameter requires a corresponding
CustomParameterBinderto be registered, even when the wrapped value isnull; implementCustomParameterBinder.bindNull(StatementContext, PreparedStatement, Integer, TargetType, Integer)if you want typed nulls to bind successfully.- Type Parameters:
K- the key typeV- the value type- Parameters:
keyType- the type of the map keysvalueType- the type of the map valuesmap- the map value; may benull- Returns:
- a
TypedParameterrepresentingMap<K,V>
-