Class TreatmentDao

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

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

    • TreatmentDao

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

    • getCreateStatement

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

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

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

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

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

      public List<Treatment> readTreatmentsByPid(long pid) throws SQLException
      Queries all treatments of a given patient id (pid) and maps the results to an ArrayList with objects of class Treatment.
      Parameters:
      pid - Patient id to query all treatments referencing this id.
      Returns:
      ArrayList with objects of class Treatment of all rows in the ResultSet.
      Throws:
      SQLException
    • getUpdateStatement

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

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