com.jenkov.mrpersister.itf
Interface IObjectReader

All Known Implementing Classes:
ObjectReader

public interface IObjectReader

This interface represents all the functions made available by the object reader of Mr. Persister. The object reader is responsible for all reading of records and turning them into objects with the values read inside.

Author:
Jakob Jenkov, Jenkov Development

Method Summary
 java.lang.Object read(IObjectMapping mapping, java.sql.PreparedStatement preparedStatement)
          Reads an object from the database using the given object mapping and PreparedStatement.
 java.lang.Object read(IObjectMapping mapping, java.sql.ResultSet result)
          Reads an object from the given ResultSet using the given object mapping.
 java.lang.Object read(IObjectMapping mapping, java.sql.Statement statement, java.lang.String sql)
          Reads an object using the provided object mapping, SQL and Statement instance.
 java.lang.Object read(IObjectMapping mapping, java.lang.String sql, java.util.Collection parameters, java.sql.Connection connection)
          Reads an object from the database using the given object mapping, SQL string, and parameters.
 java.lang.Object read(IObjectMapping mapping, java.lang.String sql, java.sql.Connection connection)
          Reads an object using the given object mappping, SQL, and the Connection instance.
 java.lang.Object read(IObjectMapping mapping, java.lang.String sql, java.lang.Object[] parameters, java.sql.Connection connection)
          Reads an object from the database using the given object mapping, SQL string, and parameters.
 java.lang.Object readByPrimaryKey(IObjectMapping mapping, IKeyValue primaryKey, java.lang.String sql, java.sql.Connection connection)
          Reads an object from the database using an object mapping, the primary key, an SQL string (explained below) and a database connection.
 java.lang.Object readByPrimaryKey(IObjectMapping mapping, java.lang.Object primaryKey, java.lang.String sql, java.sql.Connection connection)
          Reads an object from the database using an object mapping, the primary key, an SQL string (explained below) and a database connection.
 java.util.List readList(IObjectMapping mapping, java.sql.PreparedStatement preparedStatement)
          Reads a list of objects from the database using the given object mapping and PreparedStatement.
 java.util.List readList(IObjectMapping mapping, java.sql.PreparedStatement preparedStatement, IReadFilter filter)
          Reads a list of objects from the database using the given object mapping and PreparedStatement.
 java.util.List readList(IObjectMapping mapping, java.sql.ResultSet result)
          Reads a list of objects from the given ResultSet using the object mapping.
 java.util.List readList(IObjectMapping mapping, java.sql.ResultSet result, IReadFilter filter)
          Reads a list of objects from the given ResultSet using the given object mapping and read filter.
 java.util.List readList(IObjectMapping mapping, java.sql.Statement statement, java.lang.String sql)
          Reads a list of objects from the database using the given object mapping, Statement and SQL string.
 java.util.List readList(IObjectMapping mapping, java.sql.Statement statement, java.lang.String sql, IReadFilter filter)
          Reads a list of objects from the database using the given object mapping, Statement and SQL string.
 java.util.List readList(IObjectMapping mapping, java.lang.String sql, java.util.Collection parameters, java.sql.Connection connection)
          Reads a list of objects from the database using the given object mapping, SQL string, and parameters.
 java.util.List readList(IObjectMapping mapping, java.lang.String sql, java.util.Collection parameters, java.sql.Connection connection, IReadFilter filter)
          Reads a list of objects from the database using the given object mapping, SQL string, and parameters.
 java.util.List readList(IObjectMapping mapping, java.lang.String sql, java.sql.Connection connection)
          Reads a list of objects from the database using the given object mapping, SQL string, and Connection.
 java.util.List readList(IObjectMapping mapping, java.lang.String sql, java.sql.Connection connection, IReadFilter filter)
          Reads a list of objects from the database using the given object mapping, SQL string, and Connection.
 java.util.List readList(IObjectMapping mapping, java.lang.String sql, java.lang.Object[] parameters, java.sql.Connection connection)
          Reads a list of objects from the database using the given object mapping, SQL string, and parameters.
 java.util.List readList(IObjectMapping mapping, java.lang.String sql, java.lang.Object[] parameters, java.sql.Connection connection, IReadFilter filter)
          Reads a list of objects from the database using the given object mapping, SQL string, and parameters.
 java.util.List readListByPrimaryKeys(IObjectMapping mapping, java.util.Collection primaryKeys, java.lang.String sql, java.sql.Connection connection)
          Reads a list of objects from the database using an object mapping, the primary keys of the objects to read, an SQL string (explained below) and a database connection.
 java.util.List readListByPrimaryKeys(IObjectMapping mapping, java.util.Collection primaryKeys, java.lang.String sql, java.sql.Connection connection, IReadFilter filter)
          Reads a list of objects from the database using an object mapping, the primary keys of the objects to read, an SQL string (explained below) and a database connection.
 void setDatabase(Database database)
          Sets the database that this IObjectReader is supposed to read objects from.
 

Method Detail

setDatabase

void setDatabase(Database database)
Sets the database that this IObjectReader is supposed to read objects from. The Database object contains information about the features the database supports.

Parameters:
database - The database to set on this object reader.

readByPrimaryKey

java.lang.Object readByPrimaryKey(IObjectMapping mapping,
                                  java.lang.Object primaryKey,
                                  java.lang.String sql,
                                  java.sql.Connection connection)
                                  throws PersistenceException
Reads an object from the database using an object mapping, the primary key, an SQL string (explained below) and a database connection. Use this method only with single column primary keys and single object primary key values.

The SQL string has to be of the format select [field1], [field2], [field3] (etc.) from [table] where [fieldPrimaryKey] = ?. The primary key value must be a ? for use with a PreparedStatement. The object reader will insert the value in a PreparedStatement internally. The SQLGenerator class can generate a suitable SQL string for use with the object reader, so you don't have to do it yourself.

Remember to close the Connection yourself when you are done with it.

Parameters:
mapping - The object mapping to use to read this object.
primaryKey - The primary key value of the object to read from the database.
sql - The SQL generated by the SQLGenerator class (or by you if you prefer).
connection - The database connection to use for reading the object. Remember that you must close this connection yourself afterwards. The object reader only closes objects it opens itself.
Returns:
A List containing the objects read by the given primary keys. If no records were found matching the given primary keys the list returned will be empty. An empty list will also be returned if the list of primary keys is empty.
Throws:
PersistenceException - If something goes wrong during the read.

readByPrimaryKey

java.lang.Object readByPrimaryKey(IObjectMapping mapping,
                                  IKeyValue primaryKey,
                                  java.lang.String sql,
                                  java.sql.Connection connection)
                                  throws PersistenceException
Reads an object from the database using an object mapping, the primary key, an SQL string (explained below) and a database connection. This method can be used with both single column primary key tables and compound primary key tables.

The SQL string has to be of the format select [field1], [field2], [field3] (etc.) from [table] where [fieldPrimaryKey1] = ? and [fieldPrimaryKey2] = ? (etc.). The primary key value must be a ? for use with a PreparedStatement. The object reader will insert the value in a PreparedStatement internally. The SQLGenerator class can generate a suitable SQL string for use with the object reader, so you don't have to do it yourself.

Remember to close the Connection yourself when you are done with it.

Parameters:
mapping - The object mapping to use to read this object.
primaryKey - The primary key value of the object to read from the database.
sql - The SQL generated by the SQLGenerator class (or by you if you prefer).
connection - The database connection to use for reading the object. Remember that you must close this connection yourself afterwards. The object reader only closes objects it opens itself.
Returns:
A List containing the objects read by the given primary keys. If no records were found matching the given primary keys the list returned will be empty. An empty list will also be returned if the list of primary keys is empty.
Throws:
PersistenceException - If something goes wrong during the read.

read

java.lang.Object read(IObjectMapping mapping,
                      java.sql.ResultSet result)
                      throws PersistenceException
Reads an object from the given ResultSet using the given object mapping. The ResultSet has to be positioned at the record to read the object from. Not before. If the ResultSet has just been opened, you will have to call the ResultSet.next() or the ResultSet.first() before calling this method.

You must close the ResultSet yourself when you are done with it.

Parameters:
mapping - The object mapping to use to read the object.
result - The ResultSet to read the object from. Remember to close this yourself when you are done with it.
Returns:
The object read using the object mapping and the ResultSet
Throws:
PersistenceException - If anything goes wrong during the read.

read

java.lang.Object read(IObjectMapping mapping,
                      java.sql.Statement statement,
                      java.lang.String sql)
                      throws PersistenceException
Reads an object using the provided object mapping, SQL and Statement instance. The SQL can be written freely as long as it is valid, and your database understands it. If the ResultSet returned by the Statement instance returns more than one record, the first one is used to read the object. If the ResultSet is empty null is returned.

Remember to close the Statement object yourself when you are done with it.

Parameters:
mapping - The object mapping to use to read the object.
statement - The Statement instance to use to execute the SQL.
sql - The SQL that locates the record to use to read as an object.
Returns:
The object read from executing the SQL and reading the first object of the ResultSet. Null if the ResultSet is empty.
Throws:
PersistenceException - If anything goes wrong during the read.

read

java.lang.Object read(IObjectMapping mapping,
                      java.lang.String sql,
                      java.sql.Connection connection)
                      throws PersistenceException
Reads an object using the given object mappping, SQL, and the Connection instance. The SQL can be freely written as long as it is valid and your database understands it.

Remember to close the Connection instance yourself when you are done with it.

Parameters:
mapping - The object mapping to use to read the object.
sql - The SQL that locates the record in the database to read the object from.
connection - The database connection to use to read this object. Remember to close the Connection instance yourself when you are done with it.
Returns:
The object read using the SQL, object mapping and the database connection.
Throws:
PersistenceException - If anything goes wrong during the read.

read

java.lang.Object read(IObjectMapping mapping,
                      java.sql.PreparedStatement preparedStatement)
                      throws PersistenceException
Reads an object from the database using the given object mapping and PreparedStatement. You must have set all values on the PreparedStatement instance before calling this method (using the appropriate PreparedStatement.setXXX(int index, XXX value) methods ).

Remember to close the PreparedStatement instance yourself when you are done with it.

Parameters:
mapping - The object mapping to use to read this object.
preparedStatement - The PreparedStatement that locates the record that this object is to be read from.
Returns:
The object read from the database using the given object mapping and PreparedStatement
Throws:
PersistenceException - If anything goes wrong during the read.

read

java.lang.Object read(IObjectMapping mapping,
                      java.lang.String sql,
                      java.util.Collection parameters,
                      java.sql.Connection connection)
                      throws PersistenceException
Reads an object from the database using the given object mapping, SQL string, and parameters.

A PreparedStatement instance will be created using the given SQL string, and the parameters collection will be inserted into it. Therefore the SQL string should have the same format as those used with a PreparedStatement. The parameters will be inserted in the sequence returned by the parameter collection's iterator.

If the ResultSet generated by the PreparedStatement instance contains more than one record, only the first record in the ResultSet will be read into an object and returned.

Parameters:
mapping - The object mapping to use to read this object.
sql - The SQL string to use for the PreparedStatement.
parameters - The parameters to insert into the PreparedStatement.
connection - The database connection to use to create the PreparedStatement instance.
Returns:
The object read from the database.
Throws:
PersistenceException - If anything goes wrong during the read.

read

java.lang.Object read(IObjectMapping mapping,
                      java.lang.String sql,
                      java.lang.Object[] parameters,
                      java.sql.Connection connection)
                      throws PersistenceException
Reads an object from the database using the given object mapping, SQL string, and parameters.

A PreparedStatement instance will be created using the given SQL string, and the parameters in the array will be inserted into it. Therefore the SQL string should have the same format as those used with a PreparedStatement. The parameters will be inserted in the sequence of their indexes in the array, meaning parameters[0] will be inserted first.

If the ResultSet generated by the PreparedStatement instance contains more than one record, only the first record in the ResultSet will be read into an object and returned.

Parameters:
mapping - The object mapping to use to read this object.
sql - The SQL string to use for the PreparedStatement.
parameters - The parameters to insert into the PreparedStatement.
connection - The database connection to use to create the PreparedStatement instance.
Returns:
The object read from the database.
Throws:
PersistenceException - If anything goes wrong during the read.

readListByPrimaryKeys

java.util.List readListByPrimaryKeys(IObjectMapping mapping,
                                     java.util.Collection primaryKeys,
                                     java.lang.String sql,
                                     java.sql.Connection connection)
                                     throws PersistenceException
Reads a list of objects from the database using an object mapping, the primary keys of the objects to read, an SQL string (explained below) and a database connection. The SQL string has to be of the format select [field1], [field2], [field3] ... from [table] where [fieldPrimaryKey] in (?, ?, ? ...). The primary key values must be ?-marks for use with a PreparedStatement. The object reader will insert the values in a PreparedStatement internally. The SQLGenerator class can generate a suitable SQL string for use with the object reader, so you don't have to do it yourself.

Remember to close the Connection yourself when you are done with it.

Parameters:
mapping - The object mapping to use to read the objects.
primaryKeys - The primary key values of the objects to read from the database.
sql - The SQL generated by the SQLGenerator class (or by you if you prefer).
connection - The database connection to use for reading the object. Remember that you must close this connection yourself afterwards. The object reader only closes objects it opens itself.
Returns:
The objects read by the given primary key, or null if no matching record was found in the database.
Throws:
PersistenceException - If something goes wrong during the read.

readListByPrimaryKeys

java.util.List readListByPrimaryKeys(IObjectMapping mapping,
                                     java.util.Collection primaryKeys,
                                     java.lang.String sql,
                                     java.sql.Connection connection,
                                     IReadFilter filter)
                                     throws PersistenceException
Reads a list of objects from the database using an object mapping, the primary keys of the objects to read, an SQL string (explained below) and a database connection. The list of objects can be filtered by passing an IReadFilter instance to this method. If the filter parameter is null, no filtering will be done.

The SQL string has to be of the format select [field1], [field2], [field3] ... from [table] where [fieldPrimaryKey] in (?, ?, ? ...). The primary key values must be ?-marks for use with a PreparedStatement. The object reader will insert the values in a PreparedStatement internally. The SQLGenerator class can generate a suitable SQL string for use with the object reader, so you don't have to do it yourself.

Remember to close the Connection yourself when you are done with it.

Parameters:
mapping - The object mapping to use to read the objects.
primaryKeys - The primary key values of the objects to read from the database.
sql - The SQL generated by the SQLGenerator class (or by you if you prefer).
connection - The database connection to use for reading the object. Remember that you must close this connection yourself afterwards. The object reader only closes objects it opens itself.
Returns:
The objects read by the given primary key, or null if no matching record was found in the database.
Throws:
PersistenceException - If something goes wrong during the read.

readList

java.util.List readList(IObjectMapping mapping,
                        java.sql.ResultSet result)
                        throws PersistenceException
Reads a list of objects from the given ResultSet using the object mapping. The ResultSet must be positioned at the first record to be read. Not before. All records in the ResultSet will be read as objects according to the given object mapping. The list returned will contain the objects read in the same sequence as the coresponding records appear in the ResultSet.

Remember to close the ResultSet yourself when you are done with it.

Parameters:
mapping - The object mapping to use to read the objects.
result - The ResultSet to read the objects from.
Returns:
A list of objects read from the ResultSet in the same sequence as the coresponding records appear in the ResultSet
Throws:
PersistenceException - If anything goes wrong during the read.

readList

java.util.List readList(IObjectMapping mapping,
                        java.sql.ResultSet result,
                        IReadFilter filter)
                        throws PersistenceException
Reads a list of objects from the given ResultSet using the given object mapping and read filter. The ResultSet must point to the first record to be read. Not before. The read filter can either accept or reject records in the ResultSet, and can also signal that it won't accept anymore records at all, so the object reader can stop the ResultSet iteration. The object will appear in the returned list in the same sequence they are encountered in the ResultSet.

Parameters:
mapping - The object mapping to use to read the objects.
result - The ResultSet to read the objects from.
filter - The filter to apply to the ResultSet. Passing null in this parameter will result in no filtering.
Returns:
A list of objects read from the ResultSet according to the object mapping.
Throws:
PersistenceException - If anything goes wrong during the read.

readList

java.util.List readList(IObjectMapping mapping,
                        java.sql.Statement statement,
                        java.lang.String sql)
                        throws PersistenceException
Reads a list of objects from the database using the given object mapping, Statement and SQL string. The objects will appear in the list in the same sequence as they appear in the ResultSet generated by the SQL string.

Remember to close the Statement instance when you are done with it. This method will not close it.

Parameters:
mapping - The object mapping to use to read the objects.
statement - The Statement instance to use to execute the SQL string.
sql - The SQL string locating the records in the database to read into objects.
Returns:
A list of objects read from the ResultSet generated on the base of the SQL string.
Throws:
PersistenceException - If anything goes wrong during the read.

readList

java.util.List readList(IObjectMapping mapping,
                        java.sql.Statement statement,
                        java.lang.String sql,
                        IReadFilter filter)
                        throws PersistenceException
Reads a list of objects from the database using the given object mapping, Statement and SQL string. The objects will appear in the list in the same sequence as they appear in the ResultSet generated by the SQL string. The read filter can either accept or reject records in the ResultSet, and can also signal that it won't accept anymore records at all, so the object reader can stop the ResultSet iteration.

Remember to close the Statement instance when you are done with it. This method will not close it.

Parameters:
mapping - The object mapping to use to read the objects.
statement - The Statement instance to use to execute the SQL string.
sql - The SQL string locating the records in the database to read into objects.
filter - The filter to apply to the ResultSet generated from the SQL string. Passing null in this parameter will result in no filtering.
Returns:
A list of objects read from the database.
Throws:
PersistenceException - If anything goes wrong during the read.

readList

java.util.List readList(IObjectMapping mapping,
                        java.lang.String sql,
                        java.sql.Connection connection)
                        throws PersistenceException
Reads a list of objects from the database using the given object mapping, SQL string, and Connection. The objects will appear in the list in the same sequence as they appear in the ResultSet generated by the SQL string.

Remember to close the Connection instance when you are done with it. This method will not close it.

Parameters:
mapping - The object mapping to use to read the objects.
sql - The SQL string locating the records in the database to read into objects.
connection - The database connection to use to execute the SQL via.
Returns:
A list of objects read from the ResultSet generated by executing the SQL string.
Throws:
PersistenceException - If anything goes wrong during the read.

readList

java.util.List readList(IObjectMapping mapping,
                        java.lang.String sql,
                        java.sql.Connection connection,
                        IReadFilter filter)
                        throws PersistenceException
Reads a list of objects from the database using the given object mapping, SQL string, and Connection. The objects will appear in the list in the same sequence as they appear in the ResultSet generated by the SQL string. The read filter can either accept or reject records in the ResultSet, and can also signal that it won't accept anymore records at all, so the object reader can stop the ResultSet iteration.

Remember to close the Connection instance when you are done with it. This method will not close it.

Parameters:
mapping - The object mapping to use to read the objects.
sql - The SQL string locating the records in the database to read into objects.
connection - The database connection to use to execute the SQL via.
filter - The filter to apply to the ResultSet generated from the SQL string. Passing null in this parameter will result in no filtering.
Returns:
A list of objects read from the ResultSet generated by executing the SQL string.
Throws:
PersistenceException - If anything goes wrong during the read.

readList

java.util.List readList(IObjectMapping mapping,
                        java.sql.PreparedStatement preparedStatement)
                        throws PersistenceException
Reads a list of objects from the database using the given object mapping and PreparedStatement. You must have set all values on the PreparedStatement instance before calling this method (using the appropriate PreparedStatement.setXXX(int index, XXX value) methods ). The objects will appear in the list in the same sequence as they appear in the ResultSet generated by the SQL string.

Remember to close the Connection instance when you are done with it. This method will not close it.

Parameters:
mapping - The object mapping to use to read the objects.
preparedStatement - The PreparedStatement that locates the record that this object is to be read from.
Returns:
A list of objects read from the ResultSet generated by executing the PreparedStatement.
Throws:
PersistenceException - If anything goes wrong during the read.

readList

java.util.List readList(IObjectMapping mapping,
                        java.lang.String sql,
                        java.util.Collection parameters,
                        java.sql.Connection connection)
                        throws PersistenceException
Reads a list of objects from the database using the given object mapping, SQL string, and parameters.

A PreparedStatement instance will be created using the given SQL string, and the parameters collection will be inserted into it. Therefore the SQL string should have the same format as those used with a PreparedStatement. The parameters will be inserted in the sequence returned by the parameter collection's iterator.

The objects will appear in the list in the same sequence as they appear in the ResultSet generated by the SQL string.

Remember to close the Connection instance when you are done with it. This method will not close it.

Parameters:
mapping - The object mapping to use to read the list of objects.
sql - The SQL string to use for the PreparedStatement.
parameters - The parameters to insert into the PreparedStatement.
connection - The database connection to use to create the PreparedStatement instance.
Returns:
The objects read from the database.
Throws:
PersistenceException - If anything goes wrong during the read.

readList

java.util.List readList(IObjectMapping mapping,
                        java.lang.String sql,
                        java.lang.Object[] parameters,
                        java.sql.Connection connection)
                        throws PersistenceException
Reads a list of objects from the database using the given object mapping, SQL string, and parameters.

A PreparedStatement instance will be created using the given SQL string, and the parameters in the array will be inserted into it. Therefore the SQL string should have the same format as those used with a PreparedStatement. The parameters will be inserted in the sequence of their indexes in the array, meaning parameters[0] will be inserted first.

The objects will appear in the list in the same sequence as they appear in the ResultSet generated by the SQL string.

Remember to close the Connection instance when you are done with it. This method will not close it.

Parameters:
mapping - The object mapping to use to read the list of objects.
sql - The SQL string to use for the PreparedStatement.
parameters - The parameters to insert into the PreparedStatement.
connection - The database connection to use to create the PreparedStatement instance.
Returns:
The objects read from the database.
Throws:
PersistenceException - If anything goes wrong during the read.

readList

java.util.List readList(IObjectMapping mapping,
                        java.sql.PreparedStatement preparedStatement,
                        IReadFilter filter)
                        throws PersistenceException
Reads a list of objects from the database using the given object mapping and PreparedStatement. You must have set all values on the PreparedStatement instance before calling this method (using the appropriate PreparedStatement.setXXX(int index, XXX value) methods ).

The objects will appear in the list in the same sequence as they appear in the ResultSet generated by the SQL string.

The read filter can either accept or reject records in the ResultSet, and can also signal that it won't accept anymore records at all, so the object reader can stop the ResultSet iteration.

Remember to close the Connection instance when you are done with it. This method will not close it.

Parameters:
mapping - The object mapping to use to read the objects.
preparedStatement - The PreparedStatement that locates the record that this object is to be read from.
filter - The filter to apply to the ResultSet generated from the SQL string. Passing null in this parameter will result in no filtering.
Returns:
A list of objects read from the ResultSet generated by executing the PreparedStatement.
Throws:
PersistenceException - If anything goes wrong during the read.

readList

java.util.List readList(IObjectMapping mapping,
                        java.lang.String sql,
                        java.util.Collection parameters,
                        java.sql.Connection connection,
                        IReadFilter filter)
                        throws PersistenceException
Reads a list of objects from the database using the given object mapping, SQL string, and parameters.

A PreparedStatement instance will be created using the given SQL string, and the parameters collection will be inserted into it. Therefore the SQL string should have the same format as those used with a PreparedStatement. The parameters will be inserted in the sequence returned by the parameter collection's iterator.

The objects will appear in the list in the same sequence as they appear in the ResultSet generated by the SQL string.

The read filter can either accept or reject records in the ResultSet, and can also signal that it won't accept anymore records at all, so the object reader can stop the ResultSet iteration.

Remember to close the Connection instance when you are done with it. This method will not close it.

Parameters:
mapping - The object mapping to use to read the list of objects.
sql - The SQL string to use for the PreparedStatement.
parameters - The parameters to insert into the PreparedStatement.
connection - The database connection to use to create the PreparedStatement instance.
Returns:
The objects read from the database.
Throws:
PersistenceException - If anything goes wrong during the read.

readList

java.util.List readList(IObjectMapping mapping,
                        java.lang.String sql,
                        java.lang.Object[] parameters,
                        java.sql.Connection connection,
                        IReadFilter filter)
                        throws PersistenceException
Reads a list of objects from the database using the given object mapping, SQL string, and parameters.

A PreparedStatement instance will be created using the given SQL string, and the parameters in the array will be inserted into it. Therefore the SQL string should have the same format as those used with a PreparedStatement. The parameters will be inserted in the sequence of their indexes in the array, meaning parameters[0] will be inserted first.

The objects will appear in the list in the same sequence as they appear in the ResultSet generated by the SQL string.

The read filter can either accept or reject records in the ResultSet, and can also signal that it won't accept anymore records at all, so the object reader can stop the ResultSet iteration.

Remember to close the Connection instance when you are done with it. This method will not close it.

Parameters:
mapping - The object mapping to use to read the list of objects.
sql - The SQL string to use for the PreparedStatement.
parameters - The parameters to insert into the PreparedStatement.
connection - The database connection to use to create the PreparedStatement instance.
Returns:
The objects read from the database.
Throws:
PersistenceException - If anything goes wrong during the read.