I have this entity :
@Entity(name="TestEntity")
@Table(name = "TestTable")
public class TestEntity {
private Long id;
... some fields ...
private List<TestEntity> children;
@ManyToMany(cascade = CascadeType.ALL)
@Column
public List<TestEntity> getChildren() {
return children;
}
public void setChildren(List<TestEntity> children) {
this.children = children;
}
}
And I want to create a search criteria with the inner children field with something like this :
CriteriaBuilder builder = entityManager.getCriteriaBuilder();
CriteriaQuery<?> query = builder.createQuery(theClass);
Root from = query.from(theClass);
Path objectPath = from.get("children");
predicate = objectPath.in(1, 2, 3, 4, 5, 6);
Predicate ands = builder.and(predicate to array);
query.select(from).where(ands);
But I have this exception
Caused by: org.h2.jdbc.JdbcSQLException: Syntax error in SQL statement :
select testentity0_.id as id1_0_, testentity0_.code as code2_0_, testentity0_.description as descript3_0_, testentity0_.mainType as mainType4_0_ from TestTable testentity0_ cross join TestTable_TestTable children1_, TestTable testentity2_ where testentity0_.id=children1_.TestTable_id and children1_.children_id=testentity2_.id and (. in (1 , 2 , 3 , 4 , 5 , 6)) [42001-182]