Interface GroupRepository
- All Superinterfaces:
org.springframework.data.repository.CrudRepository<Group,,Long> org.springframework.data.jpa.repository.JpaRepository<Group,,Long> org.springframework.data.repository.ListCrudRepository<Group,,Long> org.springframework.data.repository.ListPagingAndSortingRepository<Group,,Long> org.springframework.data.repository.PagingAndSortingRepository<Group,,Long> org.springframework.data.repository.query.QueryByExampleExecutor<Group>,org.springframework.data.repository.Repository<Group,Long>
public interface GroupRepository
extends org.springframework.data.jpa.repository.JpaRepository<Group,Long>
Repository for groups
- Version:
- 1.3
- Author:
- Stian Lyng, Anders Austlid, Pedro Cardona
-
Method Summary
Modifier and TypeMethodDescriptionintcountAllUserInGroup(long groupId) Gets the amount of users in a group with a given group idGets link codes of all groupsfindByGroupId(long id) Finds a group by group idfindByGroupName(String name) Finds a group by group namefindByLinkCode(String linkCode) Gets a group with a given link codegetLevelByGroupId(long id) Gets group level by group idMethods inherited from interface org.springframework.data.repository.CrudRepository
count, delete, deleteAll, deleteAll, deleteAllById, deleteById, existsById, findById, saveMethods inherited from interface org.springframework.data.jpa.repository.JpaRepository
deleteAllByIdInBatch, deleteAllInBatch, deleteAllInBatch, deleteInBatch, findAll, findAll, flush, getById, getOne, getReferenceById, saveAllAndFlush, saveAndFlushMethods inherited from interface org.springframework.data.repository.ListCrudRepository
findAll, findAllById, saveAllMethods inherited from interface org.springframework.data.repository.ListPagingAndSortingRepository
findAllMethods inherited from interface org.springframework.data.repository.PagingAndSortingRepository
findAllMethods inherited from interface org.springframework.data.repository.query.QueryByExampleExecutor
count, exists, findAll, findBy, findOne
-
Method Details
-
findByGroupName
Finds a group by group name- Parameters:
name- the name of the group- Returns:
- the group with the given name if it exists
-
getLevelByGroupId
Gets group level by group id- Parameters:
id- the id of the group- Returns:
- the level of the group
-
findByGroupId
Finds a group by group id- Parameters:
id- the id of the group- Returns:
- the group with the given id if it exists
-
findAllLinkCode
Gets link codes of all groups- Returns:
- a list of all link codes
-
findByLinkCode
Gets a group with a given link code- Parameters:
linkCode- the link code of the group- Returns:
- the group with the given link code if it exists
-
countAllUserInGroup
@Query(value="SELECT count(*) FROM user_group where group_id = :groupId", nativeQuery=true) int countAllUserInGroup(@Param("groupId") long groupId) Gets the amount of users in a group with a given group id- Parameters:
groupId- the id of the group- Returns:
- the amount of users in the group
-