3

I'm using dbflow in android app and have 3 tables (simplified for brevity).

City
int cityId (PK)
String cityName

Company
int compId (PK)
String compName
int city (FK)

Employee
int empId (PK)
String empName
int city (FK)
int company (FK)

I want to join all 3 tables and use these String columns as 1 result. What i tried is following example on https://github.com/Raizlabs/DBFlow/blob/master/usage/SQLQuery.md

SQLite.select(Company_Table.EMP_ID, Company_Table.DEPT)
.from(Company.class)
.leftOuterJoin(Department.class)
.on(Company_Table.ID.withTable().eq(Department_Table.EMP_ID.withTable()))
.queryList();

so my query look something like this

List<CustomQueryModel> model = SQLite.select(Employee_Table.empName,    
     City_Table.cityName, Company_Table.compName)
     .from(Employee.class)
     .join(City.class, Join.JoinType.INNER)
     .on(Employee_Table.city.withTable().eq(City_Table.cityId.withTable()))
     .join(Company.class, Join.JoinType.INNER)
     .on(Employee_Table.company.withTable().eq(Company_Table.compId.withTable()))
     .queryCustomList(CustomQueryModel.class);

My problem is that i cant find way to get Integer value of these primary or foreign keys.

Eg. Result of Employee.city.withTable() is IntProperty, but method "eq()" parameter must be Integer and I couldnt find way to get Integer from that neither any other way for joining tables.

0 Answers0