使用ORMLite为Android,我需要建立一个由订单ID或客户名称返回订单查询。 请考虑下面的类的声明:
@DatabaseTable(tableName = "order")
public class Order {
@DatabaseField(generatedId = true)
private Long id;
@DatabaseField(foreign = true, canBeNull = false, foreignAutoRefresh = true, columnName = "customer_id")
private Customer customer;
// default constructor, getters and setters...
}
@DatabaseTable(tableName = "customer")
public class Customer {
@DatabaseField(generatedId = true)
private Long id;
@DatabaseField
private String name;
// default constructor, getters and setters...
}
原始SQL我正在寻找将是这样的:
SELECT
o.*
FROM
order o
JOIN customer c on
o.customer_id = c.id
WHERE
(o.id = ?) OR (c.name = ?)
什么是做到这一点使用ORMLite的最佳方式?