Class UserDAOImpl

java.lang.Object
com.alpaca.persistence.impl.GenericDAOImpl<User,UUID>
com.alpaca.persistence.impl.UserDAOImpl
All Implemented Interfaces:
IGenericDAO<User,UUID>, IUserDAO

@Component public class UserDAOImpl extends GenericDAOImpl<User,UUID> implements 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 Details

  • Constructor Details

    • UserDAOImpl

      public UserDAOImpl()
  • Method Details

    • getRepo

      protected GenericRepo<User,UUID> getRepo()
      Provides the repository used by the generic DAO operations.
      Specified by:
      getRepo in class GenericDAOImpl<User,UUID>
      Returns:
      the GenericRepo implementation specific to User
    • getEntity

      protected Class<User> getEntity()
      Returns the entity class managed by this DAO.
      Specified by:
      getEntity in class GenericDAOImpl<User,UUID>
      Returns:
      the Class object for User
    • findByEmail

      public Optional<User> findByEmail(String email)
      Searches for a User by email.
      Specified by:
      findByEmail in interface IUserDAO
      Parameters:
      email - the email address to search for; may be null or blank
      Returns:
      an Optional containing the found user, or empty if not found
    • updateById

      public User updateById(User user, UUID id)
      Updates an existing User identified by the given ID with the non-null and non-blank properties provided in the supplied user object. Only fields that are different, non-null, and non-blank are updated. Throws a NotFoundException if no user with the specified ID exists.
      Specified by:
      updateById in interface IGenericDAO<User,UUID>
      Parameters:
      user - user object containing updated values
      id - 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

      public boolean existsByUniqueProperties(User user)
      Determines whether a user already exists in the database based on its unique properties.
      Specified by:
      existsByUniqueProperties in interface IGenericDAO<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

      public boolean existsByEmail(String email)
      Checks whether a user exists with the given email.
      Specified by:
      existsByEmail in interface IUserDAO
      Parameters:
      email - the email to check; may be null or blank
      Returns:
      true if a user exists with the specified email, false otherwise