-
Couldn't load subscription status.
- Fork 8
Selecting values into a Map
gert-wijns edited this page Sep 1, 2016
·
1 revision
Selecting values into a Map is very similar to selecting values into a dto. In this case, the dto type is Map instead of a specific dto type.
Person person = query.from(Person.class)
// select creates proxy instance of dto class
Map<String, Object> map = query.select(Map.class)
// binds person name to the personName key in the resulting map
map.put("personName", person.getName())
=> "select hobj1.name as personName from Person hobj1"This will return a List of Maps where each map has the person name value in the personName key
Selecting values into a Map which is part of a dto is also possible.
Person person = query.from(Person.class)
// select creates proxy instance of dto class
MapsDto maps = query.select(MapsDto.class)
// Get a Map type property
Map<String, Object> map = maps.getGenericMap()
// Bind some of the map keys to values
map.put("personName", person.getName())
=> "select hobj1.name as genericMap_personName from Person hobj1"This will return a List of MapsDto where each mapsDto has a genericMap which has the person name value in the personName key