Fork me on GitHub

Query Builder (Beta)

The default way to query currently is by using the find method, where you pass the where clause and the arguments. It follows the same conventions as SQLiteDatabase query method.

Note.find(Note.class, "name = ? and title = ?", "satya", "title1");

If you have other conditions like group by, order by or limit, you could use the following method on the domain entity:

find(Class<T> type, String whereClause, String[] whereArgs, String groupBy, String orderBy, String limit)

In case you're looking to execute a custom query, you could use the following methods:

// Could execute other raw queries too here..
Note.executeQuery("VACUUM");

// for finders using raw query.
List<Note> notes = Note.findWithQuery(Note.class, "Select * from Note where name = ?", "satya");

With a Query Builder approach, you could do the following:

Select.from(TestRecord.class)
.where(Condition.prop("test").eq("satya"),
Condition.prop("prop").eq(2))
.list();

Property names are not converted currently. So, it'd be the table column names (conversion eg: testUnderscore => test_underscore, which can be obtained by calling StringUtil.toSQLName("testUnderscore")). You can find a few more examples in the SelectTest.java class.