}
private void buildFlightCriteria(Flight sample, DetachedCriteria query,
String TRIP_ALIAS, String FLIGHT_ALIAS) {
DetachedCriteria flight = query.createCriteria(TRIP_ALIAS + "."
+ FLIGHT_ALIAS, FLIGHT_ALIAS, JoinType.LEFT_OUTER_JOIN);
if (sample.getDate() != null)
flight.add(Property.forName("date").eq((sample.getDate())));
flight.add(Property.forName("operator").eq((sample.getOperator())));
DetachedCriteria originAirport = query.createCriteria(FLIGHT_ALIAS
+ ".origin", JoinType.LEFT_OUTER_JOIN);
originAirport.add(Property.forName("iataCode").eq(
sample.getOrigin().getIataCode()));
DetachedCriteria destinationAirport = query.createCriteria(FLIGHT_ALIAS
+ ".destination", JoinType.LEFT_OUTER_JOIN);
destinationAirport.add(Property.forName("iataCode").eq(
sample.getDestination().getIataCode()));
}