JOIN
https://gyazo.com/ed6df50c3b2e854f351aa2a1327e18ad #Core
Join
Sorm4j (inner or left) joins two (or three) tables with the given on condition.
code:java
List<Tuple2<Customer, Address>> result = sorm.joinOn(Customer.class, Address.class, "customer.address=address.name");
List<Tuple2<Customer, Address>> result = sorm.leftJoinOn(Customer.class, Address.class, "customer.address=address.name");
Read tuple list
If you would like to write JOIN sql directly, Sorm4j could read a result and bind to tuple of as Results container by List<Tuple2<T1,T2>> or List<Tuple3<T1,T2,T3>>.
Sorm4j considers that simple_class_name + "_DOT_ is the prefix fo column alias.
For example, If you use public class Guest{ public int id; public String name; public String address; } as Results container, the id filed is bound to not only the value of column id but also guest_DOT_id. You can also asign column alias prefix explicitly by @OrmColumnAliasPrefix annotation.
code:java
List<Tuple2<Guest, Player>> result = sorm.readTupleList(Guest.class, Player.class,
"select g.id as guest_DOT_id, g.name as guest_DOT_name, g.address as guest_DOT_address, " +
"p.id as player_DOT_id, p.name as player_DOT_name, p.address as player_DOT_address" +
"from guests g join players p on g.id=p.id");
public class Guest{ public int id; public String name; public String address; }