Package com.d3x.core.db
Interface DatabaseMapping<T>
-
- Type Parameters:
T- the type for this mapping
- All Known Implementing Classes:
Database.BasicMapping,DatabaseRecord.Mapping
public interface DatabaseMapping<T>A component that defines how a data type is mapped to a database for select, insert, update and delete operations.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceDatabaseMapping.Binder<T>A Binder that can bind a record to a PreparedStatement objectstatic interfaceDatabaseMapping.Mapper<T>A Mapper that can create an Object from the current row in a ResultSet
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static voidapplyBoolean(java.sql.PreparedStatement stmt, int paramIndex, java.lang.Boolean value)Applies the value to the statement, calling PreparedStatement.setNull() if value is nullstatic voidapplyDate(java.sql.PreparedStatement stmt, int paramIndex, java.sql.Date value)Applies the value to the statement, calling PreparedStatement.setNull() if value is nullstatic voidapplyDate(java.sql.PreparedStatement stmt, int paramIndex, java.sql.Date value, java.util.Calendar calendar)Applies the value to the statement, calling PreparedStatement.setNull() if value is nullstatic voidapplyDouble(java.sql.PreparedStatement stmt, int paramIndex, java.lang.Double value)Applies the value to the statement, calling PreparedStatement.setNull() if value is nullstatic voidapplyFloat(java.sql.PreparedStatement stmt, int paramIndex, java.lang.Float value)Applies the value to the statement, calling PreparedStatement.setNull() if value is nullstatic voidapplyInt(java.sql.PreparedStatement stmt, int paramIndex, java.lang.Integer value)Applies the value to the statement, calling PreparedStatement.setNull() if value is nullstatic voidapplyLong(java.sql.PreparedStatement stmt, int paramIndex, java.lang.Long value)Applies the value to the statement, calling PreparedStatement.setNull() if value is nullstatic voidapplyString(java.sql.PreparedStatement stmt, int paramIndex, java.lang.String value)Applies the value to the statement, calling PreparedStatement.setNull() if value is nullstatic java.sql.PreparedStatementbindArgs(java.sql.PreparedStatement stmt, java.util.List<java.lang.Object> args)Binds an array of arguments to the prepared statementstatic java.sql.PreparedStatementbindArgs(java.sql.PreparedStatement stmt, java.util.TimeZone timeZone, java.util.List<java.lang.Object> args)Binds an array of arguments to the prepared statementdefault DatabaseMapping.Binder<T>delete()The binder to bind arguments to a PreparedStatement for affecting deletesstatic <T> java.lang.StringgetDeleteSql(DatabaseMapping<T> mapping)Returns the SQL resolved from the DatabaseSql annotation on the delete methodstatic <T> java.lang.StringgetInsertSql(DatabaseMapping<T> mapping)Returns the SQL resolved from the DatabaseSql annotation on the insert methodstatic <T> java.lang.StringgetSelectSql(DatabaseMapping<T> mapping)Returns the SQL resolved from the DatabaseSql annotation on the select methodstatic java.lang.StringgetSql(DatabaseMapping<?> mapping, java.lang.String methodName)Returns the SQL resolved from the DatabaseSql annotation on the named methodstatic <T> java.lang.StringgetUpdateSql(DatabaseMapping<T> mapping)Returns the SQL resolved from the DatabaseSql annotation on the update methodstatic java.lang.Stringin(java.util.Collection<?> values)Returns a command separated list of values for an in clausestatic java.lang.Stringin(java.util.Collection<?> values, com.d3x.core.util.Option<java.time.ZoneId> zoneId)Returns a command separated list of values for an in clausedefault DatabaseMapping.Binder<T>insert()The binder to bind arguments to a PreparedStatement for affecting insertsstatic <T> java.util.Iterator<T>iterator(java.sql.ResultSet rs, DatabaseMapping.Mapper<T> mapper)Returns an iterator that extracts records from ResultSet using the mapperstatic <T> java.util.List<T>list(java.sql.ResultSet rs, DatabaseMapping.Mapper<T> mapper)Extracts records from the result set using the mapper and returns them as a liststatic com.d3x.core.util.Option<java.lang.Boolean>readBoolean(java.sql.ResultSet rs, int column)Returns an option on the value read from the ResultSetstatic com.d3x.core.util.Option<java.lang.Boolean>readBoolean(java.sql.ResultSet rs, java.lang.String column)Returns an option on the value read from the ResultSetstatic com.d3x.core.util.Option<java.sql.Date>readDate(java.sql.ResultSet rs, int column)Returns an option on the value read from the ResultSetstatic com.d3x.core.util.Option<java.sql.Date>readDate(java.sql.ResultSet rs, int column, java.util.Calendar calendar)Returns an option on the value read from the ResultSetstatic com.d3x.core.util.Option<java.sql.Date>readDate(java.sql.ResultSet rs, java.lang.String column)Returns an option on the value read from the ResultSetstatic com.d3x.core.util.Option<java.sql.Date>readDate(java.sql.ResultSet rs, java.lang.String column, java.util.Calendar calendar)Returns an option on the value read from the ResultSetstatic com.d3x.core.util.Option<java.lang.Double>readDouble(java.sql.ResultSet rs, int column)Returns an option on the value read from the ResultSetstatic com.d3x.core.util.Option<java.lang.Double>readDouble(java.sql.ResultSet rs, java.lang.String column)Returns an option on the value read from the ResultSetstatic com.d3x.core.util.Option<java.lang.Float>readFloat(java.sql.ResultSet rs, int column)Returns an option on the value read from the ResultSetstatic com.d3x.core.util.Option<java.lang.Float>readFloat(java.sql.ResultSet rs, java.lang.String column)Returns an option on the value read from the ResultSetstatic com.d3x.core.util.Option<java.lang.Integer>readInt(java.sql.ResultSet rs, int column)Returns an option on the value read from the ResultSetstatic com.d3x.core.util.Option<java.lang.Integer>readInt(java.sql.ResultSet rs, java.lang.String column)Returns an option on the value read from the ResultSetstatic com.d3x.core.util.Option<java.time.LocalDate>readLocalDate(java.sql.ResultSet rs, int column)Returns an option on the value read from the ResultSetstatic com.d3x.core.util.Option<java.time.LocalDate>readLocalDate(java.sql.ResultSet rs, java.lang.String column)Returns an option on the value read from the ResultSetstatic com.d3x.core.util.Option<java.time.LocalDateTime>readLocalDateTime(java.sql.ResultSet rs, int column)Returns an option on the value read from the ResultSetstatic com.d3x.core.util.Option<java.time.LocalDateTime>readLocalDateTime(java.sql.ResultSet rs, java.lang.String column)Returns an option on the value read from the ResultSetstatic com.d3x.core.util.Option<java.lang.Long>readLong(java.sql.ResultSet rs, int column)Returns an option on the value read from the ResultSetstatic com.d3x.core.util.Option<java.lang.Long>readLong(java.sql.ResultSet rs, java.lang.String column)Returns an option on the value read from the ResultSetstatic com.d3x.core.util.Option<java.lang.Short>readShort(java.sql.ResultSet rs, int column)Returns an option on the value read from the ResultSetstatic com.d3x.core.util.Option<java.lang.Short>readShort(java.sql.ResultSet rs, java.lang.String column)Returns an option on the value read from the ResultSetstatic com.d3x.core.util.Option<java.lang.String>readString(java.sql.ResultSet rs, int column)Returns an option on the value read from the ResultSetstatic com.d3x.core.util.Option<java.lang.String>readString(java.sql.ResultSet rs, java.lang.String column)Returns an option on the value read from the ResultSetstatic com.d3x.core.util.Option<java.sql.Time>readTime(java.sql.ResultSet rs, int column)Returns an option on the value read from the ResultSetstatic com.d3x.core.util.Option<java.sql.Time>readTime(java.sql.ResultSet rs, int column, java.util.Calendar calendar)Returns an option on the value read from the ResultSetstatic com.d3x.core.util.Option<java.sql.Time>readTime(java.sql.ResultSet rs, java.lang.String column)Returns an option on the value read from the ResultSetstatic com.d3x.core.util.Option<java.sql.Time>readTime(java.sql.ResultSet rs, java.lang.String column, java.util.Calendar calendar)Returns an option on the value read from the ResultSetstatic com.d3x.core.util.Option<java.sql.Timestamp>readTimestamp(java.sql.ResultSet rs, int column)Returns an option on the value read from the ResultSetstatic com.d3x.core.util.Option<java.sql.Timestamp>readTimestamp(java.sql.ResultSet rs, int column, java.util.Calendar calendar)Returns an option on the value read from the ResultSetstatic com.d3x.core.util.Option<java.sql.Timestamp>readTimestamp(java.sql.ResultSet rs, java.lang.String column)Returns an option on the value read from the ResultSetstatic com.d3x.core.util.Option<java.sql.Timestamp>readTimestamp(java.sql.ResultSet rs, java.lang.String column, java.util.Calendar calendar)Returns an option on the value read from the ResultSetdefault DatabaseMapping.Mapper<T>select()The mapper to map a row in a result set to some objectstatic <T> java.util.Set<T>set(java.sql.ResultSet rs, DatabaseMapping.Mapper<T> mapper)Extracts records from the result set using the mapper and returns them as a setdefault java.util.Iterator<T>toIterator(java.sql.ResultSet rs)Returns an iterator over the records generated by the ResultSetdefault java.util.List<T>toList(java.sql.ResultSet rs)Extracts all data from result set into a list using this mappingdefault java.util.Set<T>toSet(java.sql.ResultSet rs)Extracts all data from result set into a list using this mappingjava.lang.reflect.Typetype()Returns the data type for this mappingdefault DatabaseMapping.Binder<T>update()The binder to bind arguments to a PreparedStatement for affecting updates
-
-
-
Method Detail
-
type
java.lang.reflect.Type type()
Returns the data type for this mapping- Returns:
- the data type
-
select
default DatabaseMapping.Mapper<T> select()
The mapper to map a row in a result set to some object- Returns:
- the mapper to map a row in a result set to some object
-
insert
default DatabaseMapping.Binder<T> insert()
The binder to bind arguments to a PreparedStatement for affecting inserts- Returns:
- binder to bind arguments to a PreparedStatement for affecting inserts
-
update
default DatabaseMapping.Binder<T> update()
The binder to bind arguments to a PreparedStatement for affecting updates- Returns:
- binder to bind arguments to a PreparedStatement for affecting updates
-
delete
default DatabaseMapping.Binder<T> delete()
The binder to bind arguments to a PreparedStatement for affecting deletes- Returns:
- binder to bind arguments to a PreparedStatement for affecting deletes
-
readBoolean
static com.d3x.core.util.Option<java.lang.Boolean> readBoolean(java.sql.ResultSet rs, int column) throws java.sql.SQLExceptionReturns an option on the value read from the ResultSet- Parameters:
rs- the result set to read fromcolumn- the column to access- Returns:
- the option on value
- Throws:
java.sql.SQLException- if there is a SQL error
-
readBoolean
static com.d3x.core.util.Option<java.lang.Boolean> readBoolean(java.sql.ResultSet rs, java.lang.String column) throws java.sql.SQLExceptionReturns an option on the value read from the ResultSet- Parameters:
rs- the result set to read fromcolumn- the column to access- Returns:
- the option on value
- Throws:
java.sql.SQLException- if there is a SQL error
-
readShort
static com.d3x.core.util.Option<java.lang.Short> readShort(java.sql.ResultSet rs, int column) throws java.sql.SQLExceptionReturns an option on the value read from the ResultSet- Parameters:
rs- the result set to read fromcolumn- the column to access- Returns:
- the option on value
- Throws:
java.sql.SQLException- if there is a SQL error
-
readShort
static com.d3x.core.util.Option<java.lang.Short> readShort(java.sql.ResultSet rs, java.lang.String column) throws java.sql.SQLExceptionReturns an option on the value read from the ResultSet- Parameters:
rs- the result set to read fromcolumn- the column to access- Returns:
- the option on value
- Throws:
java.sql.SQLException- if there is a SQL error
-
readInt
static com.d3x.core.util.Option<java.lang.Integer> readInt(java.sql.ResultSet rs, int column) throws java.sql.SQLExceptionReturns an option on the value read from the ResultSet- Parameters:
rs- the result set to read fromcolumn- the column to access- Returns:
- the option on value
- Throws:
java.sql.SQLException- if there is a SQL error
-
readInt
static com.d3x.core.util.Option<java.lang.Integer> readInt(java.sql.ResultSet rs, java.lang.String column) throws java.sql.SQLExceptionReturns an option on the value read from the ResultSet- Parameters:
rs- the result set to read fromcolumn- the column to access- Returns:
- the option on value
- Throws:
java.sql.SQLException- if there is a SQL error
-
readLong
static com.d3x.core.util.Option<java.lang.Long> readLong(java.sql.ResultSet rs, int column) throws java.sql.SQLExceptionReturns an option on the value read from the ResultSet- Parameters:
rs- the result set to read fromcolumn- the column to access- Returns:
- the option on value
- Throws:
java.sql.SQLException- if there is a SQL error
-
readLong
static com.d3x.core.util.Option<java.lang.Long> readLong(java.sql.ResultSet rs, java.lang.String column) throws java.sql.SQLExceptionReturns an option on the value read from the ResultSet- Parameters:
rs- the result set to read fromcolumn- the column to access- Returns:
- the option on value
- Throws:
java.sql.SQLException- if there is a SQL error
-
readFloat
static com.d3x.core.util.Option<java.lang.Float> readFloat(java.sql.ResultSet rs, int column) throws java.sql.SQLExceptionReturns an option on the value read from the ResultSet- Parameters:
rs- the result set to read fromcolumn- the column to access- Returns:
- the option on value
- Throws:
java.sql.SQLException- if there is a SQL error
-
readFloat
static com.d3x.core.util.Option<java.lang.Float> readFloat(java.sql.ResultSet rs, java.lang.String column) throws java.sql.SQLExceptionReturns an option on the value read from the ResultSet- Parameters:
rs- the result set to read fromcolumn- the column to access- Returns:
- the option on value
- Throws:
java.sql.SQLException- if there is a SQL error
-
readDouble
static com.d3x.core.util.Option<java.lang.Double> readDouble(java.sql.ResultSet rs, int column) throws java.sql.SQLExceptionReturns an option on the value read from the ResultSet- Parameters:
rs- the result set to read fromcolumn- the column to access- Returns:
- the option on value
- Throws:
java.sql.SQLException- if there is a SQL error
-
readDouble
static com.d3x.core.util.Option<java.lang.Double> readDouble(java.sql.ResultSet rs, java.lang.String column) throws java.sql.SQLExceptionReturns an option on the value read from the ResultSet- Parameters:
rs- the result set to read fromcolumn- the column to access- Returns:
- the option on value
- Throws:
java.sql.SQLException- if there is a SQL error
-
readString
static com.d3x.core.util.Option<java.lang.String> readString(java.sql.ResultSet rs, int column) throws java.sql.SQLExceptionReturns an option on the value read from the ResultSet- Parameters:
rs- the result set to read fromcolumn- the column to access- Returns:
- the option on value
- Throws:
java.sql.SQLException- if there is a SQL error
-
readString
static com.d3x.core.util.Option<java.lang.String> readString(java.sql.ResultSet rs, java.lang.String column) throws java.sql.SQLExceptionReturns an option on the value read from the ResultSet- Parameters:
rs- the result set to read fromcolumn- the column to access- Returns:
- the option on value
- Throws:
java.sql.SQLException- if there is a SQL error
-
readDate
static com.d3x.core.util.Option<java.sql.Date> readDate(java.sql.ResultSet rs, int column) throws java.sql.SQLExceptionReturns an option on the value read from the ResultSet- Parameters:
rs- the result set to read fromcolumn- the column to access- Returns:
- the option on value
- Throws:
java.sql.SQLException- if there is a SQL error
-
readDate
static com.d3x.core.util.Option<java.sql.Date> readDate(java.sql.ResultSet rs, java.lang.String column) throws java.sql.SQLExceptionReturns an option on the value read from the ResultSet- Parameters:
rs- the result set to read fromcolumn- the column to access- Returns:
- the option on value
- Throws:
java.sql.SQLException- if there is a SQL error
-
readDate
static com.d3x.core.util.Option<java.sql.Date> readDate(java.sql.ResultSet rs, int column, java.util.Calendar calendar) throws java.sql.SQLExceptionReturns an option on the value read from the ResultSet- Parameters:
rs- the result set to read fromcolumn- the column to accesscalendar- the calendar to initialize date- Returns:
- the option on value
- Throws:
java.sql.SQLException- if there is a SQL error
-
readDate
static com.d3x.core.util.Option<java.sql.Date> readDate(java.sql.ResultSet rs, java.lang.String column, java.util.Calendar calendar) throws java.sql.SQLExceptionReturns an option on the value read from the ResultSet- Parameters:
rs- the result set to read fromcolumn- the column to accesscalendar- the calendar to initialize date- Returns:
- the option on value
- Throws:
java.sql.SQLException- if there is a SQL error
-
readLocalDate
static com.d3x.core.util.Option<java.time.LocalDate> readLocalDate(java.sql.ResultSet rs, int column) throws java.sql.SQLExceptionReturns an option on the value read from the ResultSet- Parameters:
rs- the result set to read fromcolumn- the column to access- Returns:
- the option on value
- Throws:
java.sql.SQLException- if there is a SQL error
-
readLocalDate
static com.d3x.core.util.Option<java.time.LocalDate> readLocalDate(java.sql.ResultSet rs, java.lang.String column) throws java.sql.SQLExceptionReturns an option on the value read from the ResultSet- Parameters:
rs- the result set to read fromcolumn- the column to access- Returns:
- the option on value
- Throws:
java.sql.SQLException- if there is a SQL error
-
readTime
static com.d3x.core.util.Option<java.sql.Time> readTime(java.sql.ResultSet rs, int column) throws java.sql.SQLExceptionReturns an option on the value read from the ResultSet- Parameters:
rs- the result set to read fromcolumn- the column to access- Returns:
- the option on value
- Throws:
java.sql.SQLException- if there is a SQL error
-
readTime
static com.d3x.core.util.Option<java.sql.Time> readTime(java.sql.ResultSet rs, java.lang.String column) throws java.sql.SQLExceptionReturns an option on the value read from the ResultSet- Parameters:
rs- the result set to read fromcolumn- the column to access- Returns:
- the option on value
- Throws:
java.sql.SQLException- if there is a SQL error
-
readTime
static com.d3x.core.util.Option<java.sql.Time> readTime(java.sql.ResultSet rs, int column, java.util.Calendar calendar) throws java.sql.SQLExceptionReturns an option on the value read from the ResultSet- Parameters:
rs- the result set to read fromcolumn- the column to accesscalendar- the calendar to initialize time- Returns:
- the option on value
- Throws:
java.sql.SQLException- if there is a SQL error
-
readTime
static com.d3x.core.util.Option<java.sql.Time> readTime(java.sql.ResultSet rs, java.lang.String column, java.util.Calendar calendar) throws java.sql.SQLExceptionReturns an option on the value read from the ResultSet- Parameters:
rs- the result set to read fromcolumn- the column to accesscalendar- the calendar to initialize time- Returns:
- the option on value
- Throws:
java.sql.SQLException- if there is a SQL error
-
readTimestamp
static com.d3x.core.util.Option<java.sql.Timestamp> readTimestamp(java.sql.ResultSet rs, int column) throws java.sql.SQLExceptionReturns an option on the value read from the ResultSet- Parameters:
rs- the result set to read fromcolumn- the column to access- Returns:
- the option on value
- Throws:
java.sql.SQLException- if there is a SQL error
-
readTimestamp
static com.d3x.core.util.Option<java.sql.Timestamp> readTimestamp(java.sql.ResultSet rs, java.lang.String column, java.util.Calendar calendar) throws java.sql.SQLExceptionReturns an option on the value read from the ResultSet- Parameters:
rs- the result set to read fromcolumn- the column to accesscalendar- the calendar to initialize timestamp- Returns:
- the option on value
- Throws:
java.sql.SQLException- if there is a SQL error
-
readTimestamp
static com.d3x.core.util.Option<java.sql.Timestamp> readTimestamp(java.sql.ResultSet rs, int column, java.util.Calendar calendar) throws java.sql.SQLExceptionReturns an option on the value read from the ResultSet- Parameters:
rs- the result set to read fromcolumn- the column to accesscalendar- the calendar to initialize timestamp- Returns:
- the option on value
- Throws:
java.sql.SQLException- if there is a SQL error
-
readTimestamp
static com.d3x.core.util.Option<java.sql.Timestamp> readTimestamp(java.sql.ResultSet rs, java.lang.String column) throws java.sql.SQLExceptionReturns an option on the value read from the ResultSet- Parameters:
rs- the result set to read fromcolumn- the column to access- Returns:
- the option on value
- Throws:
java.sql.SQLException- if there is a SQL error
-
readLocalDateTime
static com.d3x.core.util.Option<java.time.LocalDateTime> readLocalDateTime(java.sql.ResultSet rs, int column) throws java.sql.SQLExceptionReturns an option on the value read from the ResultSet- Parameters:
rs- the result set to read fromcolumn- the column to access- Returns:
- the option on value
- Throws:
java.sql.SQLException- if there is a SQL error
-
readLocalDateTime
static com.d3x.core.util.Option<java.time.LocalDateTime> readLocalDateTime(java.sql.ResultSet rs, java.lang.String column) throws java.sql.SQLExceptionReturns an option on the value read from the ResultSet- Parameters:
rs- the result set to read fromcolumn- the column to access- Returns:
- the option on value
- Throws:
java.sql.SQLException- if there is a SQL error
-
applyBoolean
static void applyBoolean(java.sql.PreparedStatement stmt, int paramIndex, java.lang.Boolean value) throws java.sql.SQLExceptionApplies the value to the statement, calling PreparedStatement.setNull() if value is null- Parameters:
stmt- the statement to apply value toparamIndex- the parameter indexvalue- the value to apply, can be null- Throws:
java.sql.SQLException- if there is a SQL error
-
applyInt
static void applyInt(java.sql.PreparedStatement stmt, int paramIndex, java.lang.Integer value) throws java.sql.SQLExceptionApplies the value to the statement, calling PreparedStatement.setNull() if value is null- Parameters:
stmt- the statement to apply value toparamIndex- the parameter indexvalue- the value to apply, can be null- Throws:
java.sql.SQLException- if there is a SQL error
-
applyLong
static void applyLong(java.sql.PreparedStatement stmt, int paramIndex, java.lang.Long value) throws java.sql.SQLExceptionApplies the value to the statement, calling PreparedStatement.setNull() if value is null- Parameters:
stmt- the statement to apply value toparamIndex- the parameter indexvalue- the value to apply, can be null- Throws:
java.sql.SQLException- if there is a SQL error
-
applyDouble
static void applyDouble(java.sql.PreparedStatement stmt, int paramIndex, java.lang.Double value) throws java.sql.SQLExceptionApplies the value to the statement, calling PreparedStatement.setNull() if value is null- Parameters:
stmt- the statement to apply value toparamIndex- the parameter indexvalue- the value to apply, can be null- Throws:
java.sql.SQLException- if there is a SQL error
-
applyFloat
static void applyFloat(java.sql.PreparedStatement stmt, int paramIndex, java.lang.Float value) throws java.sql.SQLExceptionApplies the value to the statement, calling PreparedStatement.setNull() if value is null- Parameters:
stmt- the statement to apply value toparamIndex- the parameter indexvalue- the value to apply, can be null- Throws:
java.sql.SQLException- if there is a SQL error
-
applyString
static void applyString(java.sql.PreparedStatement stmt, int paramIndex, java.lang.String value) throws java.sql.SQLExceptionApplies the value to the statement, calling PreparedStatement.setNull() if value is null- Parameters:
stmt- the statement to apply value toparamIndex- the parameter indexvalue- the value to apply, can be null- Throws:
java.sql.SQLException- if there is a SQL error
-
applyDate
static void applyDate(java.sql.PreparedStatement stmt, int paramIndex, java.sql.Date value) throws java.sql.SQLExceptionApplies the value to the statement, calling PreparedStatement.setNull() if value is null- Parameters:
stmt- the statement to apply value toparamIndex- the parameter indexvalue- the value to apply, can be null- Throws:
java.sql.SQLException- if there is a SQL error
-
applyDate
static void applyDate(java.sql.PreparedStatement stmt, int paramIndex, java.sql.Date value, java.util.Calendar calendar) throws java.sql.SQLExceptionApplies the value to the statement, calling PreparedStatement.setNull() if value is null- Parameters:
stmt- the statement to apply value toparamIndex- the parameter indexvalue- the value to apply, can be nullcalendar- the calendar to control time zone- Throws:
java.sql.SQLException- if there is a SQL error
-
toSet
default java.util.Set<T> toSet(java.sql.ResultSet rs) throws java.sql.SQLException
Extracts all data from result set into a list using this mapping- Parameters:
rs- the result set to process- Returns:
- the list of results
- Throws:
java.sql.SQLException- if there is a SQL exception
-
toList
default java.util.List<T> toList(java.sql.ResultSet rs) throws java.sql.SQLException
Extracts all data from result set into a list using this mapping- Parameters:
rs- the result set to process- Returns:
- the list of results
- Throws:
java.sql.SQLException- if there is a SQL exception
-
toIterator
default java.util.Iterator<T> toIterator(java.sql.ResultSet rs)
Returns an iterator over the records generated by the ResultSet- Parameters:
rs- the SQL result set to extract records from- Returns:
- the iterator with records
-
in
static java.lang.String in(java.util.Collection<?> values)
Returns a command separated list of values for an in clause- Parameters:
values- the list of values, for example List.of("x", "y", "z")- Returns:
- the in clause expression, for example ('x', 'y', 'z')
-
in
static java.lang.String in(java.util.Collection<?> values, com.d3x.core.util.Option<java.time.ZoneId> zoneId)Returns a command separated list of values for an in clause- Parameters:
values- the list of values, for example List.of("x", "y", "z")zoneId- the optional zone if for formatting LocalDateTime- Returns:
- the in clause expression, for example ('x', 'y', 'z')
-
bindArgs
static java.sql.PreparedStatement bindArgs(java.sql.PreparedStatement stmt, java.util.List<java.lang.Object> args) throws DatabaseExceptionBinds an array of arguments to the prepared statement- Parameters:
stmt- the prepared statement object to bind args toargs- the array of args to bind to statement- Returns:
- the statement
- Throws:
DatabaseException
-
bindArgs
static java.sql.PreparedStatement bindArgs(java.sql.PreparedStatement stmt, java.util.TimeZone timeZone, java.util.List<java.lang.Object> args) throws DatabaseExceptionBinds an array of arguments to the prepared statement- Parameters:
stmt- the prepared statement object to bind args totimeZone- the time zone for timestamp related fieldsargs- the array of args to bind to statement- Returns:
- the statement
- Throws:
DatabaseException
-
getSelectSql
static <T> java.lang.String getSelectSql(DatabaseMapping<T> mapping)
Returns the SQL resolved from the DatabaseSql annotation on the select method- Parameters:
mapping- the mapping instance- Returns:
- the SQL resolved from method
- Throws:
DatabaseException- if no annotation on method
-
getInsertSql
static <T> java.lang.String getInsertSql(DatabaseMapping<T> mapping)
Returns the SQL resolved from the DatabaseSql annotation on the insert method- Parameters:
mapping- the mapping instance- Returns:
- the SQL resolved from method
- Throws:
DatabaseException- if no annotation on method
-
getUpdateSql
static <T> java.lang.String getUpdateSql(DatabaseMapping<T> mapping)
Returns the SQL resolved from the DatabaseSql annotation on the update method- Parameters:
mapping- the mapping instance- Returns:
- the SQL resolved from method
- Throws:
DatabaseException- if no annotation on method
-
getDeleteSql
static <T> java.lang.String getDeleteSql(DatabaseMapping<T> mapping)
Returns the SQL resolved from the DatabaseSql annotation on the delete method- Parameters:
mapping- the mapping instance- Returns:
- the SQL resolved from method
- Throws:
DatabaseException- if no annotation on method
-
list
static <T> java.util.List<T> list(java.sql.ResultSet rs, DatabaseMapping.Mapper<T> mapper)Extracts records from the result set using the mapper and returns them as a list- Type Parameters:
T- the record type- Parameters:
rs- the result set to extract data frommapper- the mapper to generate records- Returns:
- the list of records
-
set
static <T> java.util.Set<T> set(java.sql.ResultSet rs, DatabaseMapping.Mapper<T> mapper)Extracts records from the result set using the mapper and returns them as a set- Type Parameters:
T- the record type- Parameters:
rs- the result set to extract data frommapper- the mapper to generate records- Returns:
- the set of records
-
iterator
static <T> java.util.Iterator<T> iterator(java.sql.ResultSet rs, DatabaseMapping.Mapper<T> mapper)Returns an iterator that extracts records from ResultSet using the mapper- Type Parameters:
T- the record type- Parameters:
rs- the result setmapper- the record mapper- Returns:
- the iterator
-
getSql
static java.lang.String getSql(DatabaseMapping<?> mapping, java.lang.String methodName)
Returns the SQL resolved from the DatabaseSql annotation on the named method- Parameters:
mapping- the mapping instancemethodName- the method name to inspect for annotation- Returns:
- the SQL resolved from method
- Throws:
DatabaseException- if no annotation on method
-
-