Package com.alpaca.persistence.impl
Class UserDAOImpl
- All Implemented Interfaces:
IGenericDAO<User,
,UUID> IUserDAO
Implementation of the
IUserDAO
interface for managing User
entities. Extends the
generic DAO implementation (GenericDAOImpl
) to provide CRUD and custom user-related
persistence operations.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
existsByEmail
(String email) Checks whether a user exists with the given email.boolean
existsByUniqueProperties
(User user) Determines whether a user already exists in the database based on its unique properties.findByEmail
(String email) Searches for aUser
by email.Returns the entity class managed by this DAO.protected GenericRepo
<User, UUID> getRepo()
Provides the repository used by the generic DAO operations.updateById
(User user, UUID id) Updates an existingUser
identified by the given ID with the non-null and non-blank properties provided in the supplieduser
object.Methods inherited from class com.alpaca.persistence.impl.GenericDAOImpl
deleteById, existsAllByIds, existsById, findAll, findAllByIds, findAllPage, findById, save, saveAll
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.alpaca.persistence.IGenericDAO
deleteById, existsAllByIds, existsById, findAll, findAllByIds, findAllPage, findById, save, saveAll
-
Field Details
-
repo
-
-
Constructor Details
-
UserDAOImpl
public UserDAOImpl()
-
-
Method Details
-
getRepo
Provides the repository used by the generic DAO operations.- Specified by:
getRepo
in classGenericDAOImpl<User,
UUID> - Returns:
- the
GenericRepo
implementation specific toUser
-
getEntity
Returns the entity class managed by this DAO.- Specified by:
getEntity
in classGenericDAOImpl<User,
UUID> - Returns:
- the
Class
object forUser
-
findByEmail
Searches for aUser
by email.- Specified by:
findByEmail
in interfaceIUserDAO
- Parameters:
email
- the email address to search for; may benull
or blank- Returns:
- an
Optional
containing the found user, or empty if not found
-
updateById
Updates an existingUser
identified by the given ID with the non-null and non-blank properties provided in the supplieduser
object. Only fields that are different, non-null, and non-blank are updated. Throws aNotFoundException
if no user with the specified ID exists.- Specified by:
updateById
in interfaceIGenericDAO<User,
UUID> - Parameters:
user
- user object containing updated valuesid
- the unique identifier of the user to update- Returns:
- the updated and saved
User
instance - Throws:
NotFoundException
- if no existing user is found with the given ID
-
existsByUniqueProperties
Determines whether a user already exists in the database based on its unique properties.- Specified by:
existsByUniqueProperties
in interfaceIGenericDAO<User,
UUID> - Parameters:
user
- the user to check; uses its email as the unique property- Returns:
true
if a user with the same email exists,false
otherwise
-
existsByEmail
Checks whether a user exists with the given email.- Specified by:
existsByEmail
in interfaceIUserDAO
- Parameters:
email
- the email to check; may benull
or blank- Returns:
true
if a user exists with the specified email,false
otherwise
-