Package edu.pdx.cs.joy.family
Class FamilyTreeDAOImpl
java.lang.Object
edu.pdx.cs.joy.family.FamilyTreeDAOImpl
- All Implemented Interfaces:
FamilyTreeDAO
Data Access Object implementation for managing FamilyTree entities in the database.
Coordinates persistence of Person and Marriage objects.
-
Constructor Summary
ConstructorsConstructorDescriptionFamilyTreeDAOImpl(Connection connection) Creates a new FamilyTreeDAOImpl with the specified database connection. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcreateTables(Connection connection) Creates all family tree related tables in the database.static voiddropTables(Connection connection) Drops all family tree related tables from the database if they exist.load()Loads a complete family tree from the database.voidsave(FamilyTree familyTree) Saves a complete family tree to the database.
-
Constructor Details
-
FamilyTreeDAOImpl
Creates a new FamilyTreeDAOImpl with the specified database connection.- Parameters:
connection- the database connection to use
-
-
Method Details
-
dropTables
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
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
Saves a complete family tree to the database. This includes all persons and marriages in the tree.- Specified by:
savein interfaceFamilyTreeDAO- Parameters:
familyTree- the family tree to save- Throws:
SQLException- if a database error occurs
-
load
Loads a complete family tree from the database. This includes all persons and marriages, with relationships properly resolved.- Specified by:
loadin interfaceFamilyTreeDAO- Returns:
- the family tree loaded from the database
- Throws:
SQLException- if a database error occurs
-