Class RoleDAOImpl

java.lang.Object
com.alpaca.persistence.impl.GenericDAOImpl<Role,UUID>
com.alpaca.persistence.impl.RoleDAOImpl
All Implemented Interfaces:
IGenericDAO<Role,UUID>, IRoleDAO

@Component public class RoleDAOImpl extends GenericDAOImpl<Role,UUID> implements IRoleDAO
Implementation of the IRoleDAO interface for managing Role entities. This class extends the generic DAO implementation (GenericDAOImpl) to provide standard CRUD operations along with custom role-specific persistence logic.
  • Field Details

  • Constructor Details

    • RoleDAOImpl

      public RoleDAOImpl()
  • Method Details

    • getRepo

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

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

      public Optional<Role> findByRoleName(String roleName)
      Retrieves a Role entity by its role name.
      Specified by:
      findByRoleName in interface IRoleDAO
      Parameters:
      roleName - the name of the role to search for; may be null or blank
      Returns:
      an Optional containing the found role, or empty if not found or invalid input
    • updateById

      public Role updateById(Role role, UUID id)
      Updates an existing Role identified by the given ID with the non-null, non-blank properties from the supplied role object. Only changed fields are applied. Throws NotFoundException if no existing entity is found.
      Specified by:
      updateById in interface IGenericDAO<Role,UUID>
      Parameters:
      role - the role object containing updated values
      id - the unique identifier of the role to update
      Returns:
      the updated and saved Role instance
      Throws:
      NotFoundException - if no role exists with the specified ID
    • existsByUniqueProperties

      public boolean existsByUniqueProperties(Role role)
      Determines whether a role already exists based on its unique properties. Both role name and description are required to be non-null and non-blank to perform the check.
      Specified by:
      existsByUniqueProperties in interface IGenericDAO<Role,UUID>
      Parameters:
      role - the role object whose uniqueness is to be verified
      Returns:
      true if a role with the same name exists; false otherwise or if input is invalid