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 Type
    Method
    Description
    int
    countAllUserInGroup(long groupId)
    Gets the amount of users in a group with a given group id
    Gets link codes of all groups
    findByGroupId(long id)
    Finds a group by group id
    Finds a group by group name
    Gets a group with a given link code
    Gets group level by group id

    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

    • findByGroupName

      Optional<Group> findByGroupName(String name)
      Finds a group by group name
      Parameters:
      name - the name of the group
      Returns:
      the group with the given name if it exists
    • getLevelByGroupId

      Optional<Long> getLevelByGroupId(long id)
      Gets group level by group id
      Parameters:
      id - the id of the group
      Returns:
      the level of the group
    • findByGroupId

      Optional<Group> findByGroupId(long id)
      Finds a group by group id
      Parameters:
      id - the id of the group
      Returns:
      the group with the given id if it exists
    • findAllLinkCode

      @Query(value="SELECT link_code FROM groups", nativeQuery=true) List<String> findAllLinkCode()
      Gets link codes of all groups
      Returns:
      a list of all link codes
    • findByLinkCode

      Optional<Group> findByLinkCode(String linkCode)
      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