DataBridge Documentation 2.0.17
A Java library for managing database connections and transactions
Loading...
Searching...
No Matches
io.github.kdesp73.databridge.helpers.Adapter Class Reference

Static Public Member Functions

static< T > List< T > load (ResultSet resultSet, Class< T > clazz)
 

Detailed Description

The Adapter class provides a utility method for mapping a ResultSet to a list of objects of a specified class type.

This class leverages reflection to map columns in the ResultSet to the fields of the provided class. It supports field names in both camelCase and snake_case.

The load method reads rows from a ResultSet and maps each row to an instance of the provided class. If any issues are encountered during mapping, they are logged using the SQLogger.

The toSnakeCase method is used to convert camelCase field names to snake_case column names, following typical database conventions.

Author
KDesp73

Member Function Documentation

◆ load()

static< T > List< T > io.github.kdesp73.databridge.helpers.Adapter.load ( ResultSet resultSet,
Class< T > clazz )
static

Maps a ResultSet to a List of objects of the specified class type.

This method iterates over the rows of the ResultSet, creating an instance of the provided class for each row. It uses reflection to match the column names from the ResultSet to the fields of the class.

Parameters
<T>The type of the object to map to.
resultSetThe ResultSet to map.
clazzThe class type to map the ResultSet to.
Returns
A List of objects of the specified class type, populated with data from the ResultSet.

The documentation for this class was generated from the following file: