0

I use Postgres in my application. I have a table where I store list of string in a column which is of type text[]. I want to use the Spring JPA Specification API to search the elements in the column.

I would like to use Specification API to search a list of entities where industries are in ['a', 'b', 'c']. This is how my entity class looks like.

@Setter
@Getter
@Entity
@Table(name = "TABLE_NAME")
@TypeDef(name = "list-array", typeClass = ListArrayType.class)
public class TableEntity {

    @Id
    @Column(name = "ID", nullable = false)
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    private Long id;

    @Type(type = "list-array")
    @Column(name = "INDUSTRIES", columnDefinition = "text[]")
    private List<String> industries;
}
Utsav Sinha
  • 605
  • 1
  • 5
  • 12
  • Does this answer your question? [How to JPA Query for Postgresql array?](https://stackoverflow.com/questions/63619548/how-to-jpa-query-for-postgresql-array) – Marc Bannout Dec 14 '22 at 08:37
  • Hey @MarcBannout. It might work, but I wanted to check if this could be done via Specification API – Utsav Sinha Dec 17 '22 at 06:25

0 Answers0