package nl.sanderhautvast.contiguous; import java.sql.ResultSet; import java.sql.SQLException; import java.util.function.Function; /** * Enables the end user to add values from JDBC to a list of results without creating Objects. * Every property must have a corresponding field in the ResultSet record (table/view/join etc) * optionally applying a name mapping if they are not equal *
* // what about null values?
* // test test test
*/
public class JdbcResults {
/**
* Adds the data to an existing CList
*
* @param result the JDBC ResultSet
* @param list The list to add to
* @throws SQLException when db throws error..
*/
public static void addAll(ResultSet result, ContiguousList> list) throws SQLException {
addAll(result, list, Function.identity());
}
/**
* Adds the data to an existing CList.
*
* The fieldNameMapper Function does not have to map for column names that do match. So only non-equal
* names have to be mapped.
*
* @param result the JDBC ResultSet
* @param list The list to add to
* @param fieldNameMapper maps the name from the element type property to the actual database column name
* @throws SQLException when db throws error..
*/
public static void addAll(ResultSet result, ContiguousList> list, Function
* The fieldNameMapper Function does not have to map for column names that do match. So only non-equal
* names have to be mapped.
*
* @param result The CList
* @param elementType the desired Object type
* @param fieldNameMapper maps the name from the element type property to the actual database column name
* @throws SQLException when db throws error..
*/
public static