-
Couldn't load subscription status.
- Fork 8
Selecting a second set of data to merge into the result
gert-wijns edited this page Sep 13, 2014
·
2 revisions
Select a subset of values into a second dto and merge during result transforming.
Person person = query.from(Person.class);
PersonDto dto = query.select(PersonDto.class);
dto.setId(person.getId());
SelectPair<Integer, String> subset = query.selectMergeValues(
dto, new SelectionMerger2<PersonDto, Integer, String>() {
public void mergeValuesIntoResult(PersonDto partialResult,
Integer personAge, String personName) {
// do custom result decoration with fetched values
}
});
subset.setFirst(person.getAge());
subset.setSecond(person.getName());
=> "select hobj1.id as id,
hobj1.age as g1__first,
hobj1.name as g1__second
from Person hobj1"A selection merger is available for up to three generic values. If you need more values you should make a separate dto class and merge them using the SelectionMerger<Result, YourDtoClass>.