Package vaultWeb.repositories
Interface ChatMessageRepository
- All Superinterfaces:
org.springframework.data.repository.CrudRepository<ChatMessage,,Long> org.springframework.data.jpa.repository.JpaRepository<ChatMessage,,Long> org.springframework.data.repository.ListCrudRepository<ChatMessage,,Long> org.springframework.data.repository.ListPagingAndSortingRepository<ChatMessage,,Long> org.springframework.data.repository.PagingAndSortingRepository<ChatMessage,,Long> org.springframework.data.repository.query.QueryByExampleExecutor<ChatMessage>,org.springframework.data.repository.Repository<ChatMessage,Long>
@Repository
public interface ChatMessageRepository
extends org.springframework.data.jpa.repository.JpaRepository<ChatMessage,Long>
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interface -
Method Summary
Modifier and TypeMethodDescriptionlongcountBySender(User sender) voiddeleteByPoll(Poll poll) intdeleteByPrivateChat(PrivateChat privateChat) findByClientMessageId(String clientMessageId) findByPrivateChatIdAndDeletedFalseOrderByTimestampAsc(Long privateChatId) findLastMessagesByPrivateChatIds(Collection<Long> privateChatIds) Returns the latest timestamp per nonempty chat without loading message payloads.findWithLockByClientMessageId(String clientMessageId) intmarkPrivateChatAsRead(Long privateChatId, Long readerId, MessageStatus read, Instant now) Marks messages sent by the other participant as READ.Methods 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
-
findByPrivateChatIdAndDeletedFalseOrderByTimestampAsc
-
findByGroupIdAndDeletedFalseOrderByTimestampAsc
-
countBySender
-
findTop10BySenderOrderByTimestampDesc
-
findLastMessagesByPrivateChatIds
@Query("select m.privateChat.id as privateChatId, max(m.timestamp) as lastMessageAt\nfrom ChatMessage m\nwhere m.privateChat.id in :privateChatIds\ngroup by m.privateChat.id\n") List<ChatMessageRepository.PrivateChatLastMessage> findLastMessagesByPrivateChatIds(@Param("privateChatIds") Collection<Long> privateChatIds) Returns the latest timestamp per nonempty chat without loading message payloads. Deleted messages remain included, matching the dashboard's existing summary behavior. -
deleteByPrivateChat
-
deleteByPoll
-
findByClientMessageId
-
findWithLockByClientMessageId
@Lock(PESSIMISTIC_WRITE) Optional<ChatMessage> findWithLockByClientMessageId(String clientMessageId) -
markPrivateChatAsRead
@Modifying @Query("update ChatMessage m\nset m.status = :read, m.readAt = :now, m.deliveredAt = coalesce(m.deliveredAt, :now)\nwhere m.privateChat.id = :privateChatId\n and m.sender.id <> :readerId\n and (m.status is null or m.status <> :read)\n") int markPrivateChatAsRead(@Param("privateChatId") Long privateChatId, @Param("readerId") Long readerId, @Param("read") MessageStatus read, @Param("now") Instant now) Marks messages sent by the other participant as READ. Never moves a status backwards.
-