使用ORMLite for Android,我需要構建一個查詢,通過訂單ID或客戶名稱返回訂單。請考慮下面的類聲明:ORMLite - 查詢國外字段
@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的最佳方式?
http://stackoverflow.com/questions/17618198/error-in-query-with-join-with-ormlite 請幫助我: (@Gray – fabiodresch 2013-07-15 21:12:14