✅ Parameter Binding
✅ Converter names
Section titled “✅ Converter names”Converter can get names, e.g. @JavaToJdbc("name").
They can only be used by an annotation @JdbcConverterName("name") on a parameter.
Names are unique per scope.
✅ Marker
Section titled “✅ Marker”The Java method parameters are mapped by their names to the corresponding JDBC named parameter markers.
The name in the JDBC string and in the Java code must be equal according UTF-8.
All JDBC named parameter markers must be defined in the Java method and vice versa.
Too many or too few parameters will lead to errors.
JDBC support ’?’ as parameter markers.
Kaumei JDBC does not support ’?’.
It uses named parameter markers, every name is prefixed with ’:’, e.g. :name
- Each
:namemust match a method parameter. Parameters that do not appear in SQL are ignored.
✅ JDBC basic types
Section titled “✅ JDBC basic types”The following JDBC Java types are mapped by default to the PreparedStatement.set... methods:
java.lang.String,java.math.BigDecimalboolean,byte,short,int,long,float,double,byte[],java.sql.Date,java.sql.Time,java.sql.Timestamp,java.sql.Clob,java.sql.Blob,java.sql.Array,java.sql.Ref,java.net.URL,java.sql.RowId,java.sql.NClob,java.sql.SQLXMLjava.sql.Struct(viasetObject)- In additional the following are supported by a default converter which maps to the
underlying
PreparedStatementmethod:java.lang.Boolean,java.lang.Byte,java.lang.Short,java.lang.Integer,java.lang.Long,java.lang.Float,java.lang.Doublechar,java.lang.Character(viasetString)
- Some JDBC driver do not support all native JDBC types, please check the documentation of your driver.
✅ Java default converter
Section titled “✅ Java default converter”- Records with a single component of a JDBC-supported type automatically gain a converter, if no converter is defined for the record.
- Enums will get automatic a converter with convert it to the name, if no converter is defined for the record.
✅ Custom converter
Section titled “✅ Custom converter”we can define converter to set JDBC values from Java
- ✅
A static simple converter which converts a value
Tinto a supported JDBC valueR:static R toDB(T value)- Parameter and return must be
unspecificornonnull. - The method must be annotated with
@JavaToJdbc
- Parameter and return must be
- ✅
A static JDBC converter which sets a value
Ron a givenPreparedStatement:static void toDB(PreparedStatement stmt, int index, T value)The parametervaluemust be nullable or unspecific. The method must handelnullcorrectly. The method must be annotated with@JavaToJdbc - ✅
A object method which is annotated with
@JavaToJdbcand returns the object value as JDBC value. The return value must be beunspecificornonnull.
✅ Collections
Section titled “✅ Collections”Arrays and single-parameter collections are expand to repeated ? placeholders
via ResultSetUtils.marks, inserting one entry per element.
- Nullable collections/arrays are not allowed
- Nullable markers for the values if the collections are allowed
- Nullable markers for the primitives in arrays are ignored