Joins - njkremer/SqliteORM GitHub Wiki

Joins can be useful for getting related Object from the database.

Joins are meant to somewhat mimic the way a join works in SQL.

Here is an example of a Join if we had Photo Object and Photographer Object and a Photographer has many photos and we want to get all the photos for a photographer given his name:

List<Photo> jimsPhotos = new SqlStatement().select(Photo.class)
    .join(Photographer.class, "id", Photo.class, "photographerId")
    .where(Photographer.class, "name").eq("Jim")
    .getList();

Note that the join() function takes a Class you're joining to and it's field to join on, as well as the field in the first Object you want to join on.

Meaning: .join(Photographer.class, "id", Photo.class, "photographerId") is the has the equivalent SQL of join photographer on photographer.id = photo.photograhperId

More specific types of Joins can be done using the JoinType class with the 5 parameter join() function.

For example: .join(Photographer.class, "id", Photo.class, "photographerId", JoinType.LEFT_OUTER)

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