I have an entity that has an collection of String:
@Entity
class A {
@Column
private Set<String> coll;
}
The sql to create the table is the following:
create table a (
coll varchar(10)[]
);
In the database, I have one column containing the array in the form of {myString1, myString2}.
I'm trying to create a Predicate/Specification to find the entities whose collection coll contains a specific value. I can't find how to do it.
I've tried stuff like:
public Specification<A> filter(String val) {
return (root, query, builder) -> {
builder.isMember(val, root.get("coll"))
};
}
But it's not working. I've seen people mentionning joins with root.join("coll"), but it's not working either, probbaly because it's not a OneToMany relation, I have nothing to join on, I just have an array of String.
Any idea?
Thanks in advance!