java.lang.Object
no.ntnu.principes.repository.AbstractRepository<Profile,Long>
no.ntnu.principes.repository.MemberRepository
- All Implemented Interfaces:
BaseRepository<Profile,Long>
Repository for managing household members/user profiles.
Provides methods for basic CRUD operations and specialized queries
for finding members by name or task status.
-
Field Summary
Fields inherited from class no.ntnu.principes.repository.AbstractRepository
dataSource, tableName -
Constructor Summary
ConstructorsConstructorDescriptionMemberRepository(DataSource dataSource) Creates a new MemberRepository with the specified data source. -
Method Summary
Modifier and TypeMethodDescriptionvoiddeleteById(Long id) Deletes a member by their ID.findAll()Retrieves all members.findAllById(List<Long> list) Finds members by multiple IDs in a single query.Finds a member by their ID.findByName(String name) Finds a member by their name.Finds all members who have completed tasks (status = DONE).Finds all members who have pending tasks (status = TODO).protected ProfileMaps a database result set row to a Profile object.Saves a member, updating if it exists or creating if it doesn't.Methods inherited from class no.ntnu.principes.repository.AbstractRepository
executeInsert, executeUpdate, queryList, queryListRaw, queryListRaw, queryOne, queryOneRaw, queryOneRaw
-
Constructor Details
-
MemberRepository
Creates a new MemberRepository with the specified data source.- Parameters:
dataSource- The JDBC data source for database connections
-
-
Method Details
-
findById
Finds a member by their ID.- Parameters:
id- The member ID- Returns:
- An Optional containing the found member or empty if not found
-
findByName
Finds a member by their name.- Parameters:
name- The member name to search for- Returns:
- An Optional containing the found member or empty if not found
-
findAll
Retrieves all members.- Returns:
- A list of all members
-
save
Saves a member, updating if it exists or creating if it doesn't.- Parameters:
member- The member to save- Returns:
- The saved member with ID populated
-
deleteById
Deletes a member by their ID.- Parameters:
id- The ID of the member to delete
-
mapRow
Maps a database result set row to a Profile object.- Specified by:
mapRowin classAbstractRepository<Profile,Long> - Parameters:
rs- The result set positioned at the row to map- Returns:
- The mapped Profile object
- Throws:
SQLException- If a database error occurs during mapping
-
findMembersWithPendingTasks
Finds all members who have pending tasks (status = TODO).- Returns:
- A list of members with pending tasks
-
findMembersWithCompletedTasks
Finds all members who have completed tasks (status = DONE).- Returns:
- A list of members with completed tasks
-
findAllById
Finds members by multiple IDs in a single query. Optimized for bulk loading of member data.- Parameters:
list- A list of member IDs to find- Returns:
- A list of members matching the provided IDs
-