Implements the Interface
DaoImp
. Overrides methods to generate specific PreparedStatements
,
to execute the specific SQL Statements.-
Field Summary
Fields inherited from class de.hitec.nhplus.datastorage.DaoImp
connection
-
Constructor Summary
ConstructorDescriptionPatientDao
(Connection connection) The constructor initiates an object ofPatientDao
and passes the connection to its super class. -
Method Summary
Modifier and TypeMethodDescriptionprotected PreparedStatement
getCreateStatement
(Patient patient) Generates aPreparedStatement
to persist the given object ofPatient
.protected PreparedStatement
getDeleteStatement
(long pid) Generates aPreparedStatement
to delete a patient with the given id.protected Patient
getInstanceFromResultSet
(ResultSet result) Maps aResultSet
of one patient to an object ofPatient
.getListFromResultSet
(ResultSet result) Maps aResultSet
of all patients to anArrayList
ofPatient
objects.protected PreparedStatement
Generates aPreparedStatement
to query all patients.protected PreparedStatement
getReadByIDStatement
(long pid) Generates aPreparedStatement
to query a patient by a given patient id (pid).protected PreparedStatement
getUpdateStatement
(Patient patient) Generates aPreparedStatement
to update the given patient, identified by the id of the patient (pid).
-
Constructor Details
-
PatientDao
The constructor initiates an object ofPatientDao
and passes the connection to its super class.- Parameters:
connection
- Object ofConnection
to execute the SQL-statements.
-
-
Method Details
-
getCreateStatement
Generates aPreparedStatement
to persist the given object ofPatient
.- Specified by:
getCreateStatement
in classDaoImp<Patient>
- Parameters:
patient
- Object ofPatient
to persist.- Returns:
PreparedStatement
to insert the given patient.
-
getReadByIDStatement
Generates aPreparedStatement
to query a patient by a given patient id (pid).- Specified by:
getReadByIDStatement
in classDaoImp<Patient>
- Parameters:
pid
- Patient id to query.- Returns:
PreparedStatement
to query the patient.
-
getInstanceFromResultSet
Maps aResultSet
of one patient to an object ofPatient
.- Specified by:
getInstanceFromResultSet
in classDaoImp<Patient>
- Parameters:
result
- ResultSet with a single row. Columns will be mapped to an object of classPatient
.- Returns:
- Object of class
Patient
with the data from the resultSet. - Throws:
SQLException
-
getReadAllStatement
Generates aPreparedStatement
to query all patients.- Specified by:
getReadAllStatement
in classDaoImp<Patient>
- Returns:
PreparedStatement
to query all patients.
-
getListFromResultSet
Maps aResultSet
of all patients to anArrayList
ofPatient
objects.- Specified by:
getListFromResultSet
in classDaoImp<Patient>
- Parameters:
result
- ResultSet with all rows. The Columns will be mapped to objects of classPatient
.- Returns:
ArrayList
with objects of classPatient
of all rows in theResultSet
.- Throws:
SQLException
-
getUpdateStatement
Generates aPreparedStatement
to update the given patient, identified by the id of the patient (pid).- Specified by:
getUpdateStatement
in classDaoImp<Patient>
- Parameters:
patient
- Patient object to update.- Returns:
PreparedStatement
to update the given patient.
-
getDeleteStatement
Generates aPreparedStatement
to delete a patient with the given id.- Specified by:
getDeleteStatement
in classDaoImp<Patient>
- Parameters:
pid
- Id of the patient to delete.- Returns:
PreparedStatement
to delete patient with the given id.
-