從我的Realm表查詢數據時出現非常奇怪的行爲。RealmResults查詢返回部分結果 - Android
例
我已經定義像這樣稱爲OrderItem
的對象:
public class OrderItem extends RealmObject{
@PrimaryKey
@Index
private long id;
//the rest of the fields here
//then getters and setters as usual
}
的問題是非常難以預測;因爲有時:
RealmResults<OrderItem> items = realm.where(OrderItem.class)
.equalTo("order_id", order_id)
.findAllSorted("id");
返回不完整的結果 - 尤其是1行;
這已被我發瘋,因爲我不能確切地找出它是如何返回這樣的部分結果;無論我在表格中有多少行!
注意
前陣子,我使用的是String
類型,在我的表的主鍵,直到我學會了如何糟糕,試圖增加值時,被一個想法;所以我切換到長這是很好的類型;除了現在我從上面的查詢得到部分結果!
我會很欣賞你這個幫助!任何想法,可以幫助我緩解這個問題的提示。
在此先感謝!
Eenvincible!
你在做什麼線程查詢哪裏得到不一致的結果?它在'doInBackground()'或類似的東西嗎?圍繞不一致的查詢顯示代碼。 – EpicPandaForce
通訊GitHub的問題https://github.com/realm/realm-java/issues/5153 –
我使用服務(後臺服務是準確的),那麼執行的ServiceHandler中的代碼; – Eenvincible