Interface CategoryRepository

All Superinterfaces:
org.springframework.data.repository.CrudRepository<Category,Long>, org.springframework.data.jpa.repository.JpaRepository<Category,Long>, org.springframework.data.repository.ListCrudRepository<Category,Long>, org.springframework.data.repository.ListPagingAndSortingRepository<Category,Long>, org.springframework.data.repository.PagingAndSortingRepository<Category,Long>, org.springframework.data.repository.query.QueryByExampleExecutor<Category>, org.springframework.data.repository.Repository<Category,Long>

@Repository public interface CategoryRepository extends org.springframework.data.jpa.repository.JpaRepository<Category,Long>
Repositorio JPA para la entidad Category. JpaRepository proporciona operaciones CRUD automáticas: - save(S entity): guarda una entidad - findById(ID id): busca por ID - findAll(): obtiene todas las entidades - deleteById(ID id): elimina por ID - count(): cuenta el número de entidades También se pueden definir consultas personalizadas usando la convención de nombres de métodos de Spring Data JPA.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Verifica si existe una categoría con el nombre dado.
    Busca una categoría por su nombre.

    Methods inherited from interface org.springframework.data.repository.CrudRepository

    count, delete, deleteAll, deleteAll, deleteAllById, deleteById, existsById, findById, save

    Methods inherited from interface org.springframework.data.jpa.repository.JpaRepository

    deleteAllByIdInBatch, deleteAllInBatch, deleteAllInBatch, deleteInBatch, findAll, findAll, flush, getById, getOne, getReferenceById, saveAllAndFlush, saveAndFlush

    Methods inherited from interface org.springframework.data.repository.ListCrudRepository

    findAll, findAllById, saveAll

    Methods inherited from interface org.springframework.data.repository.ListPagingAndSortingRepository

    findAll

    Methods inherited from interface org.springframework.data.repository.PagingAndSortingRepository

    findAll

    Methods inherited from interface org.springframework.data.repository.query.QueryByExampleExecutor

    count, exists, findAll, findBy, findOne
  • Method Details

    • findByName

      Optional<Category> findByName(String name)
      Busca una categoría por su nombre. Spring Data JPA genera automáticamente la consulta: SELECT * FROM categories WHERE name = ?
      Parameters:
      name - nombre de la categoría
      Returns:
      Optional con la categoría si existe
    • existsByName

      boolean existsByName(String name)
      Verifica si existe una categoría con el nombre dado.
      Parameters:
      name - nombre de la categoría
      Returns:
      true si existe, false en caso contrario