Class PatientDao

java.lang.Object
de.hitec.nhplus.datastorage.DaoImp<Patient>
de.hitec.nhplus.datastorage.PatientDao
All Implemented Interfaces:
Dao<Patient>

public class PatientDao extends DaoImp<Patient>
Implements the Interface DaoImp. Overrides methods to generate specific PreparedStatements, to execute the specific SQL Statements.
  • Constructor Details

    • PatientDao

      public PatientDao(Connection connection)
      The constructor initiates an object of PatientDao and passes the connection to its super class.
      Parameters:
      connection - Object of Connection to execute the SQL-statements.
  • Method Details

    • getCreateStatement

      protected PreparedStatement getCreateStatement(Patient patient)
      Generates a PreparedStatement to persist the given object of Patient.
      Specified by:
      getCreateStatement in class DaoImp<Patient>
      Parameters:
      patient - Object of Patient to persist.
      Returns:
      PreparedStatement to insert the given patient.
    • getReadByIDStatement

      protected PreparedStatement getReadByIDStatement(long pid)
      Generates a PreparedStatement to query a patient by a given patient id (pid).
      Specified by:
      getReadByIDStatement in class DaoImp<Patient>
      Parameters:
      pid - Patient id to query.
      Returns:
      PreparedStatement to query the patient.
    • getInstanceFromResultSet

      protected Patient getInstanceFromResultSet(ResultSet result) throws SQLException
      Maps a ResultSet of one patient to an object of Patient.
      Specified by:
      getInstanceFromResultSet in class DaoImp<Patient>
      Parameters:
      result - ResultSet with a single row. Columns will be mapped to an object of class Patient.
      Returns:
      Object of class Patient with the data from the resultSet.
      Throws:
      SQLException
    • getReadAllStatement

      protected PreparedStatement getReadAllStatement()
      Generates a PreparedStatement to query all patients.
      Specified by:
      getReadAllStatement in class DaoImp<Patient>
      Returns:
      PreparedStatement to query all patients.
    • getListFromResultSet

      protected ArrayList<Patient> getListFromResultSet(ResultSet result) throws SQLException
      Maps a ResultSet of all patients to an ArrayList of Patient objects.
      Specified by:
      getListFromResultSet in class DaoImp<Patient>
      Parameters:
      result - ResultSet with all rows. The Columns will be mapped to objects of class Patient.
      Returns:
      ArrayList with objects of class Patient of all rows in the ResultSet.
      Throws:
      SQLException
    • getUpdateStatement

      protected PreparedStatement getUpdateStatement(Patient patient)
      Generates a PreparedStatement to update the given patient, identified by the id of the patient (pid).
      Specified by:
      getUpdateStatement in class DaoImp<Patient>
      Parameters:
      patient - Patient object to update.
      Returns:
      PreparedStatement to update the given patient.
    • getDeleteStatement

      protected PreparedStatement getDeleteStatement(long pid)
      Generates a PreparedStatement to delete a patient with the given id.
      Specified by:
      getDeleteStatement in class DaoImp<Patient>
      Parameters:
      pid - Id of the patient to delete.
      Returns:
      PreparedStatement to delete patient with the given id.