Code
DetachedCriteria criteria2 = DetachedCriteria.forClass(MasterResult.class);
criteria2.createAlias("masterCCHolders", "masterCCHolders", CriteriaSpecification.INNER_JOIN);
criteria2.createAlias("masterFlights", "masterFlights", CriteriaSpecification.INNER_JOIN);
criteria2.createAlias("masterPassengers", "masterPassengers", CriteriaSpecification.INNER_JOIN);
criteria2.createAlias("masterVendors", "masterVendors", CriteriaSpecification.INNER_JOIN);
this is generating following query
select
this_.id as id49_4_,
this_.adults as adults49_4_,
this_.bookingdate as bookingd3_49_4_,
this_.children as children49_4_,
this_.depart_date as depart5_49_4_,
this_.email1 as email6_49_4_,
this_.fareprice as fareprice49_4_,
this_.first_name as first8_49_4_,
this_.infants as infants49_4_,
this_.last_name as last10_49_4_,
this_.phonenumber as phonenu11_49_4_,
this_.selectiontime as selecti12_49_4_,
this_.mastercurrentstatus as masterc13_49_4_,
masterccho2_.master_booking_id as master4_49_6_,
masterccho2_.id as id6_,
masterccho2_.id as id47_0_,
masterccho2_.first_name as first2_47_0_,
masterccho2_.last_name as last3_47_0_,
masterccho2_.master_booking_id as master4_47_0_,
masterflig3_.master_booking_id as master5_49_7_,
masterflig3_.id as id7_,
masterflig3_.id as id50_1_,
masterflig3_.direction as direction50_1_,
masterflig3_.fromcode as fromcode50_1_,
masterflig3_.master_booking_id as master5_50_1_,
masterflig3_.tocode as tocode50_1_,
masterpass4_.master_booking_id as master6_49_8_,
masterpass4_.id as id8_,
masterpass4_.id as id46_2_,
masterpass4_.first_name as first2_46_2_,
masterpass4_.last_name as last3_46_2_,
masterpass4_.master_booking_id as master6_46_2_,
masterpass4_.middle_name as middle4_46_2_,
masterpass4_.type as type46_2_,
mastervend5_.master_booking_id as master4_49_9_,
mastervend5_.id as id9_,
mastervend5_.id as id48_3_,
mastervend5_.locator as locator48_3_,
mastervend5_.master_booking_id as master4_48_3_,
mastervend5_.name as name48_3_
from
masterresult this_
left outer join
masterccholder masterccho2_
on this_.id=masterccho2_.master_booking_id
left outer join
masterflight masterflig3_
on this_.id=masterflig3_.master_booking_id
left outer join
masterpassenger masterpass4_
on this_.id=masterpass4_.master_booking_id
left outer join
mastervendor mastervend5_
on this_.id=mastervend5_.master_booking_id
Query returns 20 rows, which fine, but this also creates 2o Objects of masterResult.
Model structures is like
MasterResult Contains
How to solve, this issue ?
1 MasterResult Contains
So total 2*2*5=20 records.
How can I have one masterResult object which contains set of masterCCholder of size 2, set of masterflights of size 2, set of masterpassengers size of 5 and so on.
Thanks
criteria.setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY);