How create not required RealmList property
See original GitHub issueAndroid client: Realm version: 4.1.0 ROS ver. 2.8.0 Realm Studio ver. 1.18.5
Organization is create in Realm by import from json.
Here POJO.
public class Organization extends RealmObject {
@PrimaryKey
private long id;
private boolean ready = false;
@Required
private String name;
private RealmList<RealmInt> recommendations;
}
public class RealmInt extends RealmObject {
private int value;
}
When first time import orgranization from json the property recommendations
is missing. First time the organization can not contain recommendations. It’s a normal situation.
The recommendations can be update later. From another json.
That is a reason why I create property recommendations
WITHOUT annotation @Required
.
So I start my android app and login by admin credentials (download/upload). And as result it’s sync with ROS.
As result on ROS success created my custom realm with all tables. Nice.
Now in Realm Studio I save model definition in java format.
And as result I get the next Organizaion.java
public class Organization extends RealmObject {
@PrimaryKey
private long id;
private boolean ready = false;
@Required
private String name;
@Required
private RealmList<RealmInt> recommendations;
}
public class RealmInt extends RealmObject {
private int value;
}
As you can see the property recommendations
now has annotation @Required
. Why?
As I describe earlier this is not required field.
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (4 by maintainers)
I have updated Realm Studio, so you can no longer set the nullability status of lists when referencing model classes. This should prevent this situation from happening in the future. It will be in the next release of Realm Studio
@Required
never did anything on aRealmList<T extends RealmModel>
. It has no effect. That list cannot store nulls. It never could.