如何使用Ormlite在select中执行子查询。我试试这个
QueryBuilder<Group, Long> queryBuilder = groupDAO.queryBuilder();
queryBuilder.selectColumns(BaseColumns._ID ,Group.COLUMN_TITLE, "(SELECT relation_type FROM groupmembership as gr WHERE `group`._ID = gr.group_id AND gr.user_id = 687)");
但获得例外
java.lang.IllegalArgumentException: Unknown column name '(SELECT relation_type FROM groupmembership as gr WHERE `group`._ID = gr.group_id AND gr.user_id = 687)' in table groups
顺便说一下。我知道rawQuery
(),但我想使用QueryBuilder
答案 0 :(得分:0)
这是不可能的,因为QueryBuilder.selectColumns()
在添加到查询之前检查列名。
我在源代码中找到了这个
private void addSelectColumnToList(String columnName) {
verifyColumnName(columnName);
selectColumnList.add(columnName);
}