I am trying to use aliases along with the normal association names in a criteria which is giving me "duplicate association path error" my classes are as follows
class FlightReservation{
Flight flight
User usr
String title
}
class Flight {
String flightNumber
Category category
}
class Category {
String name
}
Criteria query
FlightReservation.createCriteria().list(){
createAlias("flight", "flt", CriteriaSpecification.LEFT_JOIN)
flight{
location{
eq("name", "abc")
}
}
order("flt.flightNumber", "asc")
}
Now as i think about it, it seems obvious and perhaps a Hibernate limitation so i want to know if there's an alternate approach to achieve this
I know i can use fetchMode to load the flight association but eliminating alias from the query would make things difficult for order clause( which is going to be dynamic and nesting closures would make things ugly)
One might say why can't I use "flt" (alias) in both the places? Actually this other criteria which uses the nested closure instead of alias comes from some other part of the code and I am supposed to reuse that code.
Let me know, if the question isn't clear enough, any insights on this error would be really helpful.