ORMLite连接的查询和排序 [英] ORMLite joins queries and Order by

查看:1331
本文介绍了ORMLite连接的查询和排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我特林让加入两个表,并得到双方的所有列,我这样做:

I'm tring to make join in two tables and get all columns in both, I did this:

QueryBuilder<A, Integer> aQb = aDao.queryBuilder();
QueryBuilder<B, Integer> bQb = bDao.queryBuilder();
aQb.join(bQb).prepare();

这相当于:

SELECT 'A'.* FROM A INNER JOIN B WHERE A.id = B.id;

不过,我想:

SELECT * FROM A INNER JOIN B WHERE A.id = B.id;

另一个问题是由B的领域采取订单时,如:

Other problem is when taking order by a field of B, like:

aQb.orderBy(B.COLUMN, true);

我得到一个错误说不表列B。

I get an error saying "no table column B".

推荐答案

当您使用的QueryBuilder ,它期待重返 B 的对象。他们不能在 B 包含 A 所有字段。它不会充实外商子字段,如果这是你的意思。这个功能没有穿过的精简版的屏障 ORMLite

When you are using the QueryBuilder, it is expecting to return B objects. They cannot contain all of the fields from A in B. It will not flesh out foreign sub-fields if that is what you mean. That feature has not crossed the lite barrier for ORMLite.

这是加入表排序也不支持。你当然可以添加 bQb.orderBy(B.COLUMN,真),但我不认为这会做你想要的。

Ordering on join-table is also not supported. You can certainly add the bQb.orderBy(B.COLUMN, true) but I don't think that will do what you want.

您当然可以使用原始查询的这个虽然不是最佳的。

You can certainly use raw-queries for this although it is not optimal.

这篇关于ORMLite连接的查询和排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆