Select multiple columns from two tables using gree

2019-08-03 11:05发布

I have two tables A and B and I want to write the following query using greendao.

select a.*, b.* from A a, B b where a.a_id=b.a_id;

I have achieved so far:

Adao.queryRawCreate(" , B b where T.a_id=b.a_id");

But this will return only rows from A. I need the columns from A and B both. How can i achieve this using greendao?

1条回答
走好不送
2楼-- · 2019-08-03 11:52

Greendao doesn't support joins yet.

Even if it would: greendao is an ORM-framework. This means it maps your table-rows to object. With an ORM-framework you generally traverse from object to object using the toMany and toOne relations and you don't request multiple rows to be mapped to one object.

For your problem this means you should get your desired entities of A.

If you need the corresponding B-entities you can access them through A. To be able to do so you have to specify a toMany or toOne relation between A and B (depending on your datamodel).

查看更多
登录 后发表回答