Relationships - njkremer/SqliteORM GitHub Wiki

Relationships can be specified using the @OneToMany annotation, many to many support coming later.

An example of this would be like

public class User {
 
   @PrimaryKey
   private int id;

   @OneToMany("userId")
   private List<Thing> things;
 }

Where the user will have many things.

Now to access those things given a user you can do the following:

 User nick = SqlStatement.select(User.class).where("name").eq("Nick");
 List<Thing> nicksThings = SqlStatement.select(Thing.class).from(nick).getList();

If you only wanted the things where it's value was 5 you could do:

 User nick = SqlStatement.select(User.class).where("name").eq("Nick");
 List<Thing> nicksThings = SqlStatement.select(Thing.class).from(nick).where("value").eq(5).getList();

With relationships setup you can also use Object Faulting

⚠️ **GitHub.com Fallback** ⚠️