How do I query this model of a Postgresql table with a text[] column:
@TypeDefs({
@TypeDef(
name = "string-array",
typeClass = StringArrayType.class
)
})
@Entity
@Table(name = "names")
public class Names implements Serializable
{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", nullable = false, updatable = false)
private Integer id;
@Column(name = "name", nullable = false)
private String name;
@Type(type = "string-array")
@Column(name = "tags", columnDefinition = "text[]")
private String[] tags;
...
}
This is the CrudRepository query I tried and it fails validation:
@Query("SELECT t FROM Names t WHERE :tag MEMBER OF t.tags")
Iterable<Names> findByTag(@Param("tag") String tag);
I can find examples and documentation on how to insert, update, and delete SQL arrays, but nothing on how to query them.