我在這裏問類似的問題,但我沒有得到任何滿意的答覆,所以請理解我的關注:Greendao:插入,更新,刪除語法,最佳實踐
1. https://stackoverflow.com/questions/14846105/insert-ot-update-using-one-of-the-field-as-key-in-greendao
2. https://stackoverflow.com/questions/14547288/best-way-to-select-row-with-following-scenario-using-greendao
我有一個表稱爲「TARGET」都在服務器和客戶端上。
這裏的服務器是MySql,客戶端是Android。
我想用greendao的客戶端部分, 我有多個任務待辦事項是如下:
- 員工一些EMPLOYEE_ID將得到一定日期後服務器中的所有目標,現在 在客戶端部分如果TARGET存在,那麼它應該被更新,否則插入。 這是insertOrUpdate案例。
- 使用TARGET_ID刪除特定目標。
- 使用TARGET_NAME獲取TARGET的列表。
數據關於問題:
TABLE : TARGET
FIELDS: TARGET_ID
TARGET_NAME
EMPLOYEE_ID
使用下面的代碼DaoExampleGenerator:
Best way to select row with following scenario using greenDao?
private static void addTarget(Schema schema){
Entity target = schema.addEntity("TARGET");
target.addStringProperty("TARGET_ID").primaryKey().autoincrement();
target.addStringProperty("TARGET_NAME");
target.addStringProperty("EMPLOYEE_ID");
}
下面是我已經爲我haved張貼的問題進行:
1. tDao.insertOrReplaceInTx(tArrayList);
where, tArrayList is ArrayList of TARGET Object.
2. for deleting a target using TARGET_ID, i load all the targets in
ArrayList<TARGET> then check TARGET_ID of each TARGET object. If
the TARGET_ID matches then i use, **tDao.delete(t);**
3. for this also i do the same as (2), i load all the targets then match
the TARGET_NAME, If it matches then i add it to list.
任何人都可以告訴我最好的方法來實現上述問題陳述。 使用greendao?
問題沒有意義。 – 2013-02-17 08:42:11
@MitchWheat你能告訴我你到底明白了什麼。所以我可以向你解釋我的問題。 – dreamer 2013-02-17 09:06:54