mardi 27 octobre 2015

GreenDao select in range with BETWEEN operator

I use GreenDao and I have an entity defined by this class:

Dot {
    String name;
    float value;
}

And I want to extract from my DataBase all Dots that have a value in between value - 1 and value + 1. A SQL query should be something lik this:

SELECT * FROM dot WHERE value BETWEEN(value-1, value+1)

Can I do the same in GreenDao, maybe:

QueryBuilder<Dot> query = DotDao.queryBuilder();
query.where(DotDao.Properties.Value.between(DotDao.Properties.Value-1, DotDao.Properties.Value+1));
List<Range> rangeList = query.list();

Is that possible or I have to use some Raw queries?

Aucun commentaire:

Enregistrer un commentaire