Interface PrivateChatRepository

All Superinterfaces:
org.springframework.data.repository.CrudRepository<PrivateChat,Long>, org.springframework.data.jpa.repository.JpaRepository<PrivateChat,Long>, org.springframework.data.repository.ListCrudRepository<PrivateChat,Long>, org.springframework.data.repository.ListPagingAndSortingRepository<PrivateChat,Long>, org.springframework.data.repository.PagingAndSortingRepository<PrivateChat,Long>, org.springframework.data.repository.query.QueryByExampleExecutor<PrivateChat>, org.springframework.data.repository.Repository<PrivateChat,Long>

public interface PrivateChatRepository extends org.springframework.data.jpa.repository.JpaRepository<PrivateChat,Long>
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
     
    findByUser1AndUser2(User user1, User user2)
     
    findByUser1OrUser2(User user1, User user2)
     
    findByUser2AndUser1(User user1, User user2)
     

    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

    • findByUser1AndUser2

      Optional<PrivateChat> findByUser1AndUser2(User user1, User user2)
    • findByUser2AndUser1

      Optional<PrivateChat> findByUser2AndUser1(User user1, User user2)
    • findByUser1OrUser2

      List<PrivateChat> findByUser1OrUser2(User user1, User user2)
    • existsByIdAndParticipantUsername

      @Query("SELECT CASE WHEN COUNT(pc) > 0 THEN true ELSE false END FROM PrivateChat pc WHERE pc.id = :id AND (pc.user1.username = :username OR pc.user2.username = :username)") boolean existsByIdAndParticipantUsername(@Param("id") Long id, @Param("username") String username)