Class SqlUserDao
java.lang.Object
tk.airshipcraft.commonlib.db.dao.impl.SqlUserDao
- All Implemented Interfaces:
UserDao
,GenericDao<User,
UUID>
SQL implementation of the UserDao interface for accessing and manipulating user data in a database.
This class is responsible for performing CRUD operations on User entities in the database.
- Since:
- 2023-12-27
- Version:
- 1.0.0
- Author:
- notzune
-
Constructor Summary
ConstructorsConstructorDescriptionSqlUserDao
(SqlConnectionManager connectionManager) Constructs a new SqlUserDao with a specified SqlConnectionManager. -
Method Summary
Modifier and TypeMethodDescriptionInserts a new user into the database.void
deleteById
(UUID id) Deletes a user from the database by their UUID.findAll()
Retrieves all users from the database.Retrieves a user by their unique identifier (UUID).findByUsername
(String username) Finds a user by their username.Updates an existing user in the database.
-
Constructor Details
-
SqlUserDao
Constructs a new SqlUserDao with a specified SqlConnectionManager.- Parameters:
connectionManager
- The manager responsible for providing database connections.
-
-
Method Details
-
findById
Retrieves a user by their unique identifier (UUID).- Specified by:
findById
in interfaceGenericDao<User,
UUID> - Parameters:
id
- The unique identifier of the user.- Returns:
- An
Optional<User>
containing the user if found, otherwise empty.
-
findAll
Retrieves all users from the database.- Specified by:
findAll
in interfaceGenericDao<User,
UUID> - Returns:
- A
List<User>
containing all users.
-
create
Inserts a new user into the database.- Specified by:
create
in interfaceGenericDao<User,
UUID> - Parameters:
user
- TheUser
object to insert.- Returns:
- The
User
object after insertion, with any auto-generated keys filled in.
-
update
Updates an existing user in the database.- Specified by:
update
in interfaceGenericDao<User,
UUID> - Parameters:
user
- TheUser
object to update.- Returns:
- The
User
object after it has been updated.
-
deleteById
Deletes a user from the database by their UUID.- Specified by:
deleteById
in interfaceGenericDao<User,
UUID> - Parameters:
id
- The UUID of the user to delete.
-
findByUsername
Finds a user by their username.- Specified by:
findByUsername
in interfaceUserDao
- Parameters:
username
- The username to search for.- Returns:
- The
User
object if found, otherwise null.
-