Arturo Volpe
Arturo Volpe

Reputation: 3627

Does ORMLITE support SQL EXISTS?

I am trying to query a table as follows

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

Can i do this with ORMLITE?

Upvotes: 2

Views: 2127

Answers (1)

Gray
Gray

Reputation: 116878

Yes you can. Where.exists() has been supported my ORMLite for some time. Here are the meager docs on exists.

You would do something like the following:

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();

Upvotes: 3

Related Questions