Class FamilyTreeDAOImpl

java.lang.Object
edu.pdx.cs.joy.family.FamilyTreeDAOImpl
All Implemented Interfaces:
FamilyTreeDAO

public class FamilyTreeDAOImpl extends Object implements FamilyTreeDAO
Data Access Object implementation for managing FamilyTree entities in the database. Coordinates persistence of Person and Marriage objects.
  • Constructor Details

    • FamilyTreeDAOImpl

      public FamilyTreeDAOImpl(Connection connection)
      Creates a new FamilyTreeDAOImpl with the specified database connection.
      Parameters:
      connection - the database connection to use
  • Method Details

    • dropTables

      public static void dropTables(Connection connection) throws SQLException
      Drops all family tree related tables from the database if they exist. Note: Must drop marriages first due to foreign key constraints.
      Parameters:
      connection - the database connection to use
      Throws:
      SQLException - if a database error occurs
    • createTables

      public static void createTables(Connection connection) throws SQLException
      Creates all family tree related tables in the database. Note: Must create persons first due to foreign key constraints.
      Parameters:
      connection - the database connection to use
      Throws:
      SQLException - if a database error occurs
    • save

      public void save(FamilyTree familyTree) throws SQLException
      Saves a complete family tree to the database. This includes all persons and marriages in the tree.
      Specified by:
      save in interface FamilyTreeDAO
      Parameters:
      familyTree - the family tree to save
      Throws:
      SQLException - if a database error occurs
    • load

      public FamilyTree load() throws SQLException
      Loads a complete family tree from the database. This includes all persons and marriages, with relationships properly resolved.
      Specified by:
      load in interface FamilyTreeDAO
      Returns:
      the family tree loaded from the database
      Throws:
      SQLException - if a database error occurs