Package edu.pdx.cs.joy.family
Class MarriageDAOImpl
java.lang.Object
edu.pdx.cs.joy.family.MarriageDAOImpl
- All Implemented Interfaces:
MarriageDAO
Data Access Object implementation for managing Marriage entities in the database.
-
Constructor Summary
ConstructorsConstructorDescriptionMarriageDAOImpl(Connection connection, Map<Integer, Person> personCache) Creates a new MarriageDAOImpl with the specified database connection. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcreateTable(Connection connection) Creates the marriages table in the database.voiddelete(int husbandId, int wifeId) Deletes a marriage from the database.static voiddropTable(Connection connection) Drops the marriages table from the database if it exists.findAll()Finds all marriages in the database.findByPersonId(int personId) Finds all marriages for a specific person ID.voidSaves a marriage to the database.
-
Constructor Details
-
MarriageDAOImpl
Creates a new MarriageDAOImpl with the specified database connection.- Parameters:
connection- the database connection to usepersonCache- a cache of persons to resolve marriage partners
-
-
Method Details
-
dropTable
Drops the marriages table from the database if it exists.- Parameters:
connection- the database connection to use- Throws:
SQLException- if a database error occurs
-
createTable
Creates the marriages table in the database.- Parameters:
connection- the database connection to use- Throws:
SQLException- if a database error occurs
-
save
Saves a marriage to the database.- Specified by:
savein interfaceMarriageDAO- Parameters:
marriage- the marriage to save- Throws:
SQLException- if a database error occurs
-
findByPersonId
Finds all marriages for a specific person ID.- Specified by:
findByPersonIdin interfaceMarriageDAO- Parameters:
personId- the person ID- Returns:
- a list of marriages involving the person
- Throws:
SQLException- if a database error occurs
-
findAll
Finds all marriages in the database.- Specified by:
findAllin interfaceMarriageDAO- Returns:
- a list of all marriages
- Throws:
SQLException- if a database error occurs
-
delete
Deletes a marriage from the database.- Specified by:
deletein interfaceMarriageDAO- Parameters:
husbandId- the husband's IDwifeId- the wife's ID- Throws:
SQLException- if a database error occurs
-