associateの例 を Immutable Entity でどうするか
Employee_ e = new Employee_();
Task_ t = new Task_();
Address_ a = new Address_();
Map<Employee, Tuple2<List<Task>, Optional<Address>>> result = nativeql
.from(e)
.innerJoin(t, on -> on.eq(e.id, t.asiginee))
.innerJoin(a, on -> on.eq(e.addressId, a.addressId))
.orderBy(c -> c.asc(e.employeeName))
.select(e, t, a)
.collect(
groupingBy(
Tuple3::getItem1,
teeing(
mapping(Tuple3::getItem2, toList()),
mapping(Tuple3::getItem3, first()),
Tuple2::new
)
)
);
inner join なのに Address がOptionalになってしまうのと、Tuple3::getItem1
とかが何を表してるか分かりづらい……。
joined entity type から entity type を取り出すのに Metamodel のメソッドが使えると解決するかも?