ORMLITE是否支持SQL EXISTS?

时间:2012-02-15 13:47:44

标签: java android ormlite

我正在尝试按如下方式查询表

select * from client c
    where EXISTS (select * from visit v where c._id = v.client_id)

我可以用ORMLITE吗?

1 个答案:

答案 0 :(得分:3)

是的,你可以。我的Where.exists()已经支持ORMLite一段时间了。以下是[微薄]文档:

  

http://ormlite.com/docs/exists

您可以执行以下操作:

QueryBuilder<Visit, Integer> visitQb = visitDao.queryBuilder();
visitQb.where().eq(Visit.CLIENT_ID_FIELD, client.getId());
QueryBuilder<Client, Integer> clientQb = clientDao.queryBuilder();
clientQb.where().exists(visitQb);
List<Client> results = clientQb.query();