Skip to content Skip to sidebar Skip to footer

Realm Find Queries Result In Empty Objects

When doing find queries for objects I'm getting 'empty' objects (non-null, but not populated). However, in the debugger I can see the data for the object in the object description

Solution 1:

The idea behind realm-java is that we are generating Proxy class inherits from user's model class, and override the setters and getters there.

It is totally normal that you see null values for the model's field in the debugger, since the Realm are not setting them. (zero-copy, Realm is trying to reduce the memory usage by managing the data in the native code and sharing them whenever it is possible.)

Because of this, when you want to access a Realm model's field, please always use setters and getters. Checking the generated Proxy class will help you to understand this, it is quite simple actually. It is located in the build directory named like MyModelRealmProxy.java

And also check this section of the documents, it would give you some idea about the standalone object and how to write them to Realm.

Post a Comment for "Realm Find Queries Result In Empty Objects"