public class MyEntity {
@DatabaseField(columnName = "ID", generatedId = true)
private int id;
@DatabaseField(columnName = "PARENT", foreign = true)
private MyEntity parent;
}
And i want to make a query returning all MyEntity which are parent of another MyEntity.
So what I did:
public List<MyEntity> getAllParents() throws SQLException {
QueryBuilder<MyEntity, Integer> queryBuilderChilds = queryBuilder();
queryBuilderChilds.where().isNotNull("PARENT");
queryBuilderChilds.selectColumns("PARENT");
QueryBuilder<MyEntity, Integer> queryBuilderParent = queryBuilder();
queryBuilderParent.where().in("ID", queryBuilderChilds);
return queryBuilderParent.query();
}
But the doc say that when you use "selectColumns, the ID is automatically added. So i got a queryBuilder with 2 columns and my second where().in() throws :
java.sql.SQLException: There must be only 1 result column in sub-query but we found 2
Thanks for reading