Java – realm: create a relationship by ID
Suppose I have several domain objects (tables) with many connections between them, and I haven't pre filled all the objects
I want to be able to create a relationship through their ID (primary key)
For example, I have a JSON file where one object has an ID list of another object (not an actual object, although another object already exists in domain dB). I want to be able to fill these objects directly into the objects without querying them first
How is that possible?
Solution
Real is designed as an object database without impedance errors, which can be realized by mapping Java objects to entries in the table The relationship in realm is handled specifically to comply with the above principles
For example, you can describe the relationship between the following objects
public class ObjectA extends RealmObject { ... @PrimaryKey private long id; ... } public class ObjectB extends RealmObject { ... private RealmList<ObjectA> entries; ... }
The relationship you want, that is, through the primarykey ID, seems very close to the relational database and is not supported