Groups Repository

@Repository
interface GroupsRepository : JpaRepository<T, ID>

The GroupsRepository interface is useful to manage the queries for the groups

Author

N7ghtm4r3 - Tecknobit

See also

JpaRepository

Functions

Link copied to clipboard
@Modifying(clearAutomatically = true )
@Query(value = "INSERT INTO " + PROJECTS_GROUPS_TABLE + "(" + PROJECT_IDENTIFIER_KEY + "," + GROUP_IDENTIFIER_KEY + ") VALUES (" + ":" + PROJECT_IDENTIFIER_KEY + "," + ":" + GROUP_IDENTIFIER_KEY + ")", nativeQuery = true )
abstract fun addGroupProject(@Param(value = "project_id") projectId: String, @Param(value = "group_id") groupId: String)
Method to execute the query to add a project to a group
Link copied to clipboard
abstract fun <S : T?> count(example: Example<S>): Long
Link copied to clipboard
@Modifying(clearAutomatically = true )
@Query(value = "INSERT INTO " + GROUPS_KEY + "( " + IDENTIFIER_KEY + "," + NAME_KEY + "," + GROUP_LOGO_KEY + "," + CREATION_DATE_KEY + "," + GROUP_DESCRIPTION_KEY + "," + AUTHOR_KEY + ") VALUES " + "( " + ":" + IDENTIFIER_KEY + "," + ":" + NAME_KEY + "," + ":" + GROUP_LOGO_KEY + "," + ":" + CREATION_DATE_KEY + "," + ":" + GROUP_DESCRIPTION_KEY + "," + ":" + AUTHOR_KEY + ")", nativeQuery = true )
abstract fun createGroup(@Param(value = "author") author: String, @Param(value = "id") groupId: String, @Param(value = "name") groupName: String, @Param(value = "logo") logo: String, @Param(value = "creation_date") creationDate: Long, @Param(value = "group_description") groupDescription: String)
Method to execute the query to create a new Group
Link copied to clipboard
abstract fun delete(entity: T)
Link copied to clipboard
abstract fun deleteAll(entities: Iterable<out T>)
Link copied to clipboard
abstract fun deleteAllById(ids: Iterable<out ID>)
Link copied to clipboard
abstract fun deleteAllByIdInBatch(ids: Iterable<ID>)
Link copied to clipboard
abstract fun deleteAllInBatch(entities: Iterable<T>)
Link copied to clipboard
abstract fun deleteById(id: ID)
Link copied to clipboard
@Modifying(clearAutomatically = true )
@Query(value = ""DELETE FROM " + GROUPS_KEY + " WHERE " + GROUPS_KEY + ".id=:" + GROUP_IDENTIFIER_KEY", nativeQuery = true )
abstract fun deleteGroup(@Param(value = "group_id") groupId: String)
Method to execute the query to delete an existing Group
Link copied to clipboard
open fun deleteInBatch(entities: Iterable<T>)
Link copied to clipboard
@Modifying(clearAutomatically = true )
@Query(value = ""UPDATE " + GROUPS_KEY + " SET " + NAME_KEY + "=:" + NAME_KEY + "," + GROUP_DESCRIPTION_KEY + "=:" + GROUP_DESCRIPTION_KEY + " WHERE " + IDENTIFIER_KEY + "=:" + IDENTIFIER_KEY", nativeQuery = true )
abstract fun editGroup(@Param(value = "id") groupId: String, @Param(value = "name") groupName: String, @Param(value = "group_description") groupDescription: String)
@Modifying(clearAutomatically = true )
@Query(value = ""UPDATE " + GROUPS_KEY + " SET " + GROUP_LOGO_KEY + "=:" + GROUP_LOGO_KEY + "," + NAME_KEY + "=:" + NAME_KEY + "," + GROUP_DESCRIPTION_KEY + "=:" + GROUP_DESCRIPTION_KEY + " WHERE " + IDENTIFIER_KEY + "=:" + IDENTIFIER_KEY", nativeQuery = true )
abstract fun editGroup(@Param(value = "id") groupId: String, @Param(value = "logo") logo: String, @Param(value = "name") groupName: String, @Param(value = "group_description") groupDescription: String)
Method to execute the query to edit an existing Group
Link copied to clipboard
abstract fun <S : T?> exists(example: Example<S>): Boolean
Link copied to clipboard
abstract fun existsById(id: ID): Boolean
Link copied to clipboard
abstract fun <S : T?> findAll(example: Example<S>): List<S>
abstract fun findAll(): Iterable<T>
abstract fun findAll(): List<T>
abstract fun findAll(pageable: Pageable): Page<T>
abstract fun <S : T?> findAll(example: Example<S>): Iterable<S>
abstract fun <S : T?> findAll(example: Example<S>, pageable: Pageable): Page<S>
Link copied to clipboard
abstract fun findAllById(ids: Iterable<ID>): Iterable<T>
abstract fun findAllById(ids: Iterable<ID>): List<T>
Link copied to clipboard
abstract fun <S : T?, R> findBy(example: Example<S>, queryFunction: (FluentQuery.FetchableFluentQuery<S>) -> R): R
Link copied to clipboard
abstract fun findById(id: ID): Optional<T>
Link copied to clipboard
abstract fun <S : T?> findOne(example: Example<S>): Optional<S>
Link copied to clipboard
abstract fun flush()
Link copied to clipboard
@Query(value = "SELECT * FROM " + GROUPS_KEY + " WHERE " + AUTHOR_KEY + "=:" + AUTHOR_KEY + " AND " + NAME_KEY + " LIKE %:" + NAME_KEY + "%" + " ORDER BY " + CREATION_DATE_KEY + " DESC ", nativeQuery = true )
abstract fun getAuthoredGroups(@Param(value = "author") userId: String, @Param(value = "name") name: String, pageable: Pageable): List<Group>
Method to execute the query to select the list of a Group where the user is the author of the group
Link copied to clipboard
@Query(value = "SELECT COUNT(*) FROM " + GROUPS_KEY + " WHERE " + AUTHOR_KEY + "=:" + AUTHOR_KEY + " AND " + NAME_KEY + " LIKE %:" + NAME_KEY + "%", nativeQuery = true )
abstract fun getAuthoredGroupsCount(@Param(value = "author") userId: String, @Param(value = "name") name: String): Long
Method to execute the query to count the total groups where the user is the author of the group
Link copied to clipboard
abstract fun getById(id: ID): T
Link copied to clipboard
@Query(value = ""SELECT " + GROUPS_KEY + ".* FROM " + GROUPS_KEY + " AS " + GROUPS_KEY + " INNER JOIN " + GROUP_MEMBERS_TABLE + " ON " + GROUPS_KEY + "." + IDENTIFIER_KEY + " = " + GROUP_MEMBERS_TABLE + "." + GROUP_MEMBER_KEY + " WHERE " + GROUP_MEMBERS_TABLE + "." + IDENTIFIER_KEY + "=:" + AUTHOR_KEY + " AND " + GROUPS_KEY + "." + IDENTIFIER_KEY + "=:" + GROUP_IDENTIFIER_KEY", nativeQuery = true )
abstract fun getGroup(@Param(value = "author") userId: String, @Param(value = "group_id") groupId: String): Group
Method to execute the query to select a Group by its id
Link copied to clipboard
@Query(value = ""SELECT * FROM " + GROUPS_KEY + " WHERE " + AUTHOR_KEY + "=:" + AUTHOR_KEY + " AND " + NAME_KEY + "=:" + NAME_KEY", nativeQuery = true )
abstract fun getGroupByName(@Param(value = "author") userId: String, @Param(value = "name") name: String): Group
Method to execute the query to select a Group by its name
Link copied to clipboard
@Modifying(clearAutomatically = true )
@Query(value = ""SELECT " + PROJECT_IDENTIFIER_KEY + " FROM " + PROJECTS_GROUPS_TABLE + " WHERE " + GROUP_IDENTIFIER_KEY + "=:" + GROUP_IDENTIFIER_KEY", nativeQuery = true )
abstract fun getGroupProjectsIds(@Param(value = "group_id") groupId: String): List<String>
Method to execute the query to select the list of a Project's id of a group
Link copied to clipboard
@Query(value = "SELECT groups.* FROM " + GROUPS_KEY + " AS groups LEFT JOIN " + GROUP_MEMBERS_TABLE + " ON groups." + IDENTIFIER_KEY + " = group_members." + GROUP_MEMBER_KEY + " WHERE " + GROUP_MEMBERS_TABLE + "." + IDENTIFIER_KEY + "=:" + AUTHOR_KEY + " AND " + GROUP_MEMBERS_TABLE + "." + INVITATION_STATUS_KEY + " = " + "'JOINED'" + " ORDER BY " + CREATION_DATE_KEY + " DESC ", nativeQuery = true )
abstract fun getGroups(@Param(value = "author") userId: String): List<Group>
@Query(value = "SELECT groups.* FROM " + GROUPS_KEY + " AS groups LEFT JOIN " + GROUP_MEMBERS_TABLE + " ON groups." + IDENTIFIER_KEY + " = group_members." + GROUP_MEMBER_KEY + " WHERE " + GROUP_MEMBERS_TABLE + "." + IDENTIFIER_KEY + "=:" + AUTHOR_KEY + " AND " + "groups." + NAME_KEY + " LIKE %:" + NAME_KEY + "%" + " AND (" + "COALESCE(:" + ROLES_FILTER_KEY + ") IS NULL" + " OR " + GROUP_MEMBERS_TABLE + "." + MEMBER_ROLE_KEY + " IN (:" + ROLES_FILTER_KEY + ")" + ") AND " + GROUP_MEMBERS_TABLE + "." + INVITATION_STATUS_KEY + " = " + "'JOINED'" + " ORDER BY " + CREATION_DATE_KEY + " DESC ", nativeQuery = true )
abstract fun getGroups(@Param(value = "author") userId: String, @Param(value = "name") name: String, @Param(value = "roles") roles: List<String>, pageable: Pageable): List<Group>
Method to execute the query to select the list of a Group
Link copied to clipboard
@Query(value = "SELECT COUNT(*) FROM " + GROUPS_KEY + " AS groups LEFT JOIN " + GROUP_MEMBERS_TABLE + " ON groups." + IDENTIFIER_KEY + " = group_members." + GROUP_MEMBER_KEY + " WHERE " + GROUP_MEMBERS_TABLE + "." + IDENTIFIER_KEY + "=:" + AUTHOR_KEY + " AND " + "groups." + NAME_KEY + " LIKE %:" + NAME_KEY + "%" + " AND (" + "COALESCE(:" + ROLES_FILTER_KEY + ") IS NULL" + " OR " + GROUP_MEMBERS_TABLE + "." + MEMBER_ROLE_KEY + " IN (:" + ROLES_FILTER_KEY + ")" + ") AND " + GROUP_MEMBERS_TABLE + "." + MEMBER_ROLE_KEY + " IN (:" + ROLES_FILTER_KEY + ")" + " AND " + GROUP_MEMBERS_TABLE + "." + INVITATION_STATUS_KEY + " = " + "'JOINED'", nativeQuery = true )
abstract fun getGroupsCount(@Param(value = "author") userId: String, @Param(value = "name") name: String, @Param(value = "roles") roles: List<String>): Long
Method to execute the query to count the total groups where the user is a GroupMember
Link copied to clipboard
abstract fun getOne(id: ID): T
Link copied to clipboard
abstract fun getReferenceById(id: ID): T
Link copied to clipboard
@Modifying(clearAutomatically = true )
@Query(value = ""DELETE FROM " + PROJECTS_GROUPS_TABLE + " WHERE " + PROJECT_IDENTIFIER_KEY + "=:" + PROJECT_IDENTIFIER_KEY + " AND " + GROUP_IDENTIFIER_KEY + "=:" + GROUP_IDENTIFIER_KEY", nativeQuery = true )
abstract fun removeGroupProject(@Param(value = "project_id") projectId: String, @Param(value = "group_id") groupId: String)
Method to execute the query to remove a project from a group
Link copied to clipboard
abstract fun <S : T?> save(entity: S): S
Link copied to clipboard
abstract fun <S : T?> saveAll(entities: Iterable<S>): Iterable<S>
abstract fun <S : T?> saveAll(entities: Iterable<S>): List<S>
Link copied to clipboard
abstract fun <S : T?> saveAllAndFlush(entities: Iterable<S>): List<S>
Link copied to clipboard
abstract fun <S : T?> saveAndFlush(entity: S): S