Ormlite Inner Join in five tables

0

I want to create some JOIN in five tables like this example:

SELECT * FROM TableA AS TA
    INNER JOIN TableB AS TB ON TA.Id = TB.IdTA
    INNER JOIN TableC AS TC ON TB.IdTC = TC.Id
    INNER JOIN TableD AS TD ON TC.Id = TD.IdTC
    INNER JOIN TableE AS TE ON TD.IdTE = TE.Id
WHERE TE.Id = 30085

Note: TableB and TableD are tables N-M

I'm a bit confused on how to do this in Ormlite's Android, could anyone help me with this query or provide me with a step-by-step?

    
asked by anonymous 11.04.2014 / 14:05

1 answer

1

Adapted answer from here :

It will be something like this (adapting to your example) :

// Começa a primeira query
QueryBuilder<TableA, Integer> TableAQb = TableADao.queryBuilder();
QueryBuilder<TableB, Integer> TableBQb = TableBDao.queryBuilder();
// Join entre TableA e TableB 
TableAQb.join(TableBQb);
//TERCEIRA QUERY
QueryBuilder<TableC, Integer> TableCQb =
    TableCDao.queryBuilder();
TableCQb.where().gt("mixedvalue", 100);
// join TableC
TableCQb.join(TableAQb);
List<TableC> TableCQb.query();

So following the other tables.

Remembering that "raw queries" are supported, including the Dao.queryRaw() " where you can use your own query. Follow documentation .

    
11.04.2014 / 15:19