How do i write criteria api for the below entity of type string-array
@Table(name = "Test")
public class Test
{
@Type(type = "string-array")
@Column(name = "tempCol",columnDefinition = "text[]")
public List<String> sampleColumnList;
}
Query
//value={"abc,"def"}
private Predicate getPredicate(List<String> value,entityManager e)
{
CriteriaBuilder cb = entityManager.getCriteriaBuilder();
CriteriaQuery<SampleColumn> cq = cb.createQuery(SampleColumn.class);
Root<SampleColumn> root = cq.from(SampleColumn.class);
Object[] strArray1 = new Object[] {value};
Expression<Object[]> exp=root.get("tempCol");
Predicate predicate = cb.and(exp.in(strArray1));
cq.select(root).where(predicate);
TypedQuery<Test> tp = entityManager.createQuery(cq);
List<Test>c=tp.getResultList();
}
I tried the above method but I am trying to query for records with abc, def as values from tempCol
i keep getting the exception The provided abc is not Object[] or List!,i tried with list instead of Object[] as well still didn't work. What am I doing wrong