境界关系领域始终空 [英] Realm relation field always null
本文介绍了境界关系领域始终空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有我的模型:
public class RChat extends RealmObject {
@PrimaryKey
private String Id;
private RMyTest Test;
public RChat() {}
}
和
public class RMyTest extends RealmObject {
@PrimaryKey
private String myName;
public RMyTest() {
}
}
和我使用的是这样的:
mRealm = Realm.getInstance(this);
mRealm.beginTransaction();
final RChat chat = mRealm.createObject(RChat.class);
chat.setId("test");
RMyTest rProfile = mRealm.createObject(RMyTest.class);
rProfile.setMyName("alireza test");
chat.setTest(rProfile);
//mRealm.copyToRealmOrUpdate(chat);
mRealm.commitTransaction();
RChat chat1 = mRealm.where(RChat.class).equalTo("Id","test").findFirst();
但客服1
对象的测试
字段有null值始终。我怎样才能解决这个问题?
but the chat1
object's Test
field has null value always. How can I fix this problem?
推荐答案
我在想我的对象必须不能直接为空,但问题是领域使用代理的模式和代理不为null其实。
I was thinking my objects must not be null directly but the point is Realm uses proxy for models and the proxy is not null actually.
这篇关于境界关系领域始终空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文