Skip to content

Instantly share code, notes, and snippets.

@PierceZ
Created September 3, 2017 14:45
Show Gist options
  • Save PierceZ/2c89c98cbad847780c3962f2002baca6 to your computer and use it in GitHub Desktop.
Save PierceZ/2c89c98cbad847780c3962f2002baca6 to your computer and use it in GitHub Desktop.
A one-to-many example for ObjectBox.
@Entity
public class Zoo {
@Id
private long id;
// a Zoo can have many Animals
@Backlink
ToMany<Animal> animals;
...
}
@Entity
public class Animal {
@Id(assignable = true)
private long id;
private String name;
private boolean flying;
private boolean swimming;
private boolean walking;
// an Animal belongs to one Zoo
ToOne<Zoo> zoo;
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment