Grails Association Duplicate Error Criteria

I am trying to use aliases along with normal association names in a criterion which gives me a "duplicate association path error", my classes look like this

class FlightReservation{
    Flight flight
    User usr
    String title
 }

class Flight {
    String flightNumber
    Category category

}

class Category {
    String name 
}

      

Request criteria

 FlightReservation.createCriteria().list(){
     createAlias("flight", "flt", CriteriaSpecification.LEFT_JOIN)

     flight{
       location{
        eq("name", "abc")
      }
    }


     order("flt.flightNumber", "asc")

}

      

Now that I think about it, it seems obvious and maybe a limitation of Hibernate so I want to know if there is an alternative approach to achieve this

I know I can use fetchMode to load the aviation association but excluding the alias from the request will make it harder for the order proposal (which will be dynamic, and closing the closure will make things ugly)

Can you tell me why I can't use "flt" (alias) in both places? Actually this other criterion, which uses a nested closure instead of an alias, comes from some other part of the code, and I have to reuse that code.

Let me know if the question is not clear enough, any details on this error would be really helpful.

+3
duplicates grails associations criteria


source to share


No one has answered this question yet

See similar questions:

4
Grails - Concatenate twice in criteria API

or similar:

1657
Find duplicate values ​​in a SQL table
1194
Remove duplicate values ​​from JS array
1170
How do I remove duplicate lines?
856
Removing duplicates in lists
709
How do I remove duplicates from a list while maintaining order?
623
Find duplicate records in MySQL
615
Posting the file and related data to a RESTful WebService preferably in JSON
8
Grails: find one-to-many associations with String
1
Grails / Groovy: changing query closure at runtime
1
Grails with criteria



All Articles
Loading...
X
Show
Funny
Dev
Pics