Request Grails Criteria to Duplicate Instances

I have a domain class called Order, and this class is related hasManyto the class Item. When I request a list of orders with certain restrictions, I get as many copies Orderas I have items.

So, for example, an Orderinstance refers to 3 instances Item, then a query for criteria on Orderreturns 3 duplicate instances Order. I'm not sure, but if it's worth mentioning that the domain class Orderhas fetchModeit set to "eager".

I am really puzzled by what is going on there. Any help in this regard will be greatly appreciated. Code snippet added:

def clazz = "cust.Order"
def criteria = clazz.createCriteria()
        println("clazz == "+Order.list())// returning correct data i.e unique instance of order
        def filter = {
                    // trimmed down all filtering criteria for debugging
            }//close filter
        List results = criteria.list(max:params?.max,offset:params?.offset,filter)
            results.each{Object data->
                println(data.getClass())
            }
        println("results == "+results)

Thanks again

+5
4

API - SQL-. JOINs (- ) Orders . .

- Set, :

def resultSet = new HashSet()
resultSet.addAll(results)
println("results == " + resultSet)
+2

criteria.listDistinct criteria.list,

+3

:

resultTransformer org.hibernate.Criteria.DISTINCT_ROOT_ENTITY
+3

, Order.findAllBy *. :)

0

All Articles