0

I have a PostgreSQL table where channel_ids field is BIGINT[]. In console I can search like so:

select * FROM user where 10000=ANY(channel_ids).

But I can't figure out how to build up the Specification for search in JpaRepository.

public interface UserRepository extends JpaRepository<User, Long> {

    Page<User> findAll(Specification<User> spec, Pageable pageable);
}

Is it even supported?

Martlark
  • 14,208
  • 13
  • 83
  • 99
Riho
  • 4,523
  • 3
  • 33
  • 48
  • Seems you have to use a collection I believe: https://stackoverflow.com/questions/22935278/is-it-possible-to-use-an-array-object-as-a-parameter-in-spring-repository-query?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa – Derrops May 21 '18 at 06:18
  • This one seems different as he wants to search by some value in array, i.e. id in (1000,10001). I need the opposite 10000= ANY(ids) – Riho May 21 '18 at 06:40
  • I know but I just meant that you have to use a collection. – Derrops May 21 '18 at 06:46
  • Why not do a select on channel table to match the user and the id you wanted? – Alexandru Hodis May 21 '18 at 06:56

0 Answers0