Created
September 3, 2017 14:45
-
-
Save PierceZ/2c89c98cbad847780c3962f2002baca6 to your computer and use it in GitHub Desktop.
A one-to-many example for ObjectBox.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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