My need was as follows: A report that would bring the Event and the number of hotel reservations that were associated with that Event. And so it was followed as shown in the code below:
List<IHotelReservation> iHotelReservationList = Lists.newArrayList();
iHotelReservationList.addAll(this.hotelReservationDao.listByReservationStatus(hotelReservationFilter));
iHotelReservationList.addAll(this.omnibeesHotelReservationDao.listByReservationStatus(hotelReservationFilter));
Map<Event, Integer> hotelReservationMap = Maps.newHashMap();
for (IHotelReservation iHotelReservation : iHotelReservationList) {
int hotelReservationQtd = 1;
if (hotelReservationMap.containsKey(iHotelReservation.getEvent())) {
hotelReservationQtd = hotelReservationMap.get(iHotelReservation.getEvent())+1;
}
hotelReservationMap.put(iHotelReservation.getEvent(), hotelReservationQtd);
}
this.result.include("hotelReservationMap", hotelReservationMap);
}
I still need to return a Map using Event as the key. But now with the number of Allocations given that Event, no more than HotelReservations. It is worth mentioning that I have a List getAllocationList () in IHotelReservation.