Interface GoalRepository
- All Superinterfaces:
org.springframework.data.repository.CrudRepository<Goal,
,Long> org.springframework.data.jpa.repository.JpaRepository<Goal,
,Long> org.springframework.data.repository.ListCrudRepository<Goal,
,Long> org.springframework.data.repository.ListPagingAndSortingRepository<Goal,
,Long> org.springframework.data.repository.PagingAndSortingRepository<Goal,
,Long> org.springframework.data.repository.query.QueryByExampleExecutor<Goal>
,org.springframework.data.repository.Repository<Goal,
Long>
public interface GoalRepository
extends org.springframework.data.jpa.repository.JpaRepository<Goal,Long>
Repository interface responsible for communicating with the data layer in relation to the Goal entity.
- Since:
- 22.4.24
- Version:
- 1.0
- Author:
- Harry X.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
deleteByIdAndUser
(Long id, User user) Transactional method used for deleting a goal of a userorg.springframework.data.domain.Page
<Goal> findAllByCompletedOnIsNotNullAndUser
(User user, org.springframework.data.domain.Pageable pageable) Finds a page of saving goals of a user that are complete/inactive (completedOn is not null)Finds all saving goals of a user that are active (completedOn is null)Finds all saving goals of a user that are active (completedOn is null), sorted by priority, from lowest value (high priority) to highest (low priority)org.springframework.data.domain.Page
<Goal> findAllByUser
(User user, org.springframework.data.domain.Pageable pageable) Finds a page of all saving goal entities of a userfindByIdAndUser
(Long id, User user) Finds the goal of a user specified by its id, wrapped by an Optional object.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
-
findAllByUser
org.springframework.data.domain.Page<Goal> findAllByUser(User user, org.springframework.data.domain.Pageable pageable) Finds a page of all saving goal entities of a user- Parameters:
user
- User who owns the goalspageable
- Configures the page parameters- Returns:
- Page of all saving goals of a user
-
findByIdAndUser
Finds the goal of a user specified by its id, wrapped by an Optional object. If the goal does not exist or does not belong to the user, the Optional wraps nothing- Parameters:
id
- Identifies a goaluser
- User who owns the goal- Returns:
- Optional of the specified goal, else returns Optional wrapped around nothing
-
findAllByCompletedOnIsNullAndUser
Finds all saving goals of a user that are active (completedOn is null)- Parameters:
user
- The user, owning the goals- Returns:
- List of active goals
-
findAllByCompletedOnIsNotNullAndUser
org.springframework.data.domain.Page<Goal> findAllByCompletedOnIsNotNullAndUser(User user, org.springframework.data.domain.Pageable pageable) Finds a page of saving goals of a user that are complete/inactive (completedOn is not null)- Parameters:
user
- The user, owning the goalspageable
- Pageable object to paginate the return value- Returns:
- A page of completed goals
-
findAllByCompletedOnIsNullAndUserOrderByPriorityAsc
Finds all saving goals of a user that are active (completedOn is null), sorted by priority, from lowest value (high priority) to highest (low priority)- Parameters:
user
- The user, owning the goals- Returns:
- List of active goals
-
deleteByIdAndUser
Transactional method used for deleting a goal of a user- Parameters:
id
- Identifies the goaluser
- User that owns the Goal
-