Package edu.pdx.cs.joy.jdbc
Interface DepartmentDAO
- All Known Implementing Classes:
DepartmentDAOImpl
public interface DepartmentDAO
Data Access Object interface for managing Department entities in the database.
-
Method Summary
Modifier and TypeMethodDescriptionvoiddelete(int id) Deletes a department from the database by ID.findAll()Finds all departments in the database.findById(int id) Finds a department by its ID.findByName(String name) Finds a department by its name.voidsave(Department department) Saves a department to the database.voidupdate(Department department) Updates an existing department in the database.
-
Method Details
-
save
Saves a department to the database. The department's ID will be automatically generated by the database.- Parameters:
department- the department to save- Throws:
SQLException- if a database error occurs
-
findById
Finds a department by its ID.- Parameters:
id- the ID to search for- Returns:
- the department with the given ID, or null if not found
- Throws:
SQLException- if a database error occurs
-
findByName
Finds a department by its name.- Parameters:
name- the name to search for- Returns:
- the department with the given name, or null if not found
- Throws:
SQLException- if a database error occurs
-
findAll
Finds all departments in the database.- Returns:
- a list of all departments
- Throws:
SQLException- if a database error occurs
-
update
Updates an existing department in the database.- Parameters:
department- the department to update- Throws:
SQLException- if a database error occurs
-
delete
Deletes a department from the database by ID.- Parameters:
id- the ID of the department to delete- Throws:
SQLException- if a database error occurs
-