Schnittstelle ContactRepository
- Alle Superschnittstellen:
org.springframework.data.repository.CrudRepository<Contact,
,Long> org.springframework.data.jpa.repository.JpaRepository<Contact,
,Long> org.springframework.data.repository.ListCrudRepository<Contact,
,Long> org.springframework.data.repository.ListPagingAndSortingRepository<Contact,
,Long> org.springframework.data.repository.PagingAndSortingRepository<Contact,
,Long> org.springframework.data.repository.query.QueryByExampleExecutor<Contact>
,org.springframework.data.repository.Repository<Contact,
Long>
public interface ContactRepository
extends org.springframework.data.jpa.repository.JpaRepository<Contact,Long>
Repository interface for accessing and managing contact entities in the database.
-
Methodenübersicht
Modifizierer und TypMethodeBeschreibungvoid
deleteContactsByUserId
(Long userId) IN case of a user is deleted, all his contacts will be deletedboolean
existsByUserIds
(Long userId1, Long userId2) Checks whether a contact relationship exists between two users, regardless of which user was the requester or receiver.findByBlockedByIdAndContactStatus
(Long blockedById, ContactStatus contactStatus) Finds all blocked contacts where the given user is the one who performed the blocking.findByReceiverIdAndContactStatus
(Long receiverId, ContactStatus contactStatus) Finds all contacts where the given user is the receiver and the contact has the specified status.findByRequesterIdAndContactStatus
(Long requesterId, ContactStatus contactStatus) Finds all contacts where the given user is the requester and the contact has the specified status.findByUserIdAndContactStatus
(Long userId, ContactStatus contactStatus) Finds all contacts for a given requesterId or receiverId.Von Schnittstelle geerbte Methoden org.springframework.data.repository.CrudRepository
count, delete, deleteAll, deleteAll, deleteAllById, deleteById, existsById, findById, save
Von Schnittstelle geerbte Methoden org.springframework.data.jpa.repository.JpaRepository
deleteAllByIdInBatch, deleteAllInBatch, deleteAllInBatch, deleteInBatch, findAll, findAll, flush, getById, getOne, getReferenceById, saveAllAndFlush, saveAndFlush
Von Schnittstelle geerbte Methoden org.springframework.data.repository.ListCrudRepository
findAll, findAllById, saveAll
Von Schnittstelle geerbte Methoden org.springframework.data.repository.ListPagingAndSortingRepository
findAll
Von Schnittstelle geerbte Methoden org.springframework.data.repository.PagingAndSortingRepository
findAll
Von Schnittstelle geerbte Methoden org.springframework.data.repository.query.QueryByExampleExecutor
count, exists, findAll, findBy, findOne
-
Methodendetails
-
existsByUserIds
@Query("SELECT CASE WHEN COUNT(c) > 0 THEN true ELSE false END\nFROM Contact c\nWHERE (c.requester.id = :userId1 AND c.receiver.id = :userId2)\n OR (c.requester.id = :userId2 AND c.receiver.id = :userId1)\n") boolean existsByUserIds(Long userId1, Long userId2) Checks whether a contact relationship exists between two users, regardless of which user was the requester or receiver.- Parameter:
userId1
- the ID of the first useruserId2
- the ID of the second user- Gibt zurück:
- true if a contact already exists between the two users, false otherwise
-
findByUserIdAndContactStatus
@Query("SELECT c\nFROM Contact c\nWHERE (c.requester.id = :userId OR c.receiver.id = :userId)\n AND c.contactStatus = :contactStatus\n") List<Contact> findByUserIdAndContactStatus(Long userId, ContactStatus contactStatus) Finds all contacts for a given requesterId or receiverId. Filters the contacts according to the given status.- Parameter:
userId
- the ID of the requester or receivercontactStatus
- the contact status- Gibt zurück:
- a list of
Contact
entities.
-
findByReceiverIdAndContactStatus
Finds all contacts where the given user is the receiver and the contact has the specified status.- Parameter:
receiverId
- the ID of the receivercontactStatus
- the status of the contact- Gibt zurück:
- a list of
Contact
entities
-
findByRequesterIdAndContactStatus
Finds all contacts where the given user is the requester and the contact has the specified status.- Parameter:
requesterId
- the ID of the requestercontactStatus
- the status of the contact- Gibt zurück:
- a list of
Contact
entities
-
findByBlockedByIdAndContactStatus
Finds all blocked contacts where the given user is the one who performed the blocking.- Parameter:
blockedById
- the ID of the user who blocked the contactcontactStatus
- the status of the contact (should be BLOCKED)- Gibt zurück:
- a list of
Contact
entities
-
deleteContactsByUserId
@Modifying @Query("DELETE FROM Contact c WHERE c.receiver.id = :userId OR c.requester.id = :userId\n") void deleteContactsByUserId(Long userId) IN case of a user is deleted, all his contacts will be deleted- Parameter:
userId
- the ID of the user that should be deleted
-