gorm - Grails Criteria multiple hasMany intersection -


i've been trying query multiple hasmany objects, such as:

def product = product.createcriteria().list {   createalias("productattributevalues", "pav")        , {          if (session.filters?.filter_instore) {         , {           eq("pav.attribute", attribute.findbycode("instore"))           eq("pav.valuede", session.filters?.filter_instore?.tostring())         }     }      if (session.filters?.filter_promo) {       , {         eq("pav.attribute", attribute.findbycode("promo"))         eq("pav.valuede", "1")       }     }   }     } 

this doesn't seem work, since never result set, although have test data match. seems problem i'm querying twice same objects.

one possible solution query productattributevalues seperately , intersect "in"("mypavs", pavs) - seems inefficient me.

any thoughts? thanks.

i re-build query so:

def products = product.withcriteria{   productattributevalues{         or{       if (session.filters?.filter_instore) {         , {           eq("attribute", attribute.findbycode("instore"))           eq("valuede", session.filters?.filter_instore?.tostring())         }       }        if (session.filters?.filter_promo) {         , {           eq("attribute", attribute.findbycode("promo"))           eq("valuede", "1")        }       }     }   }     } 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -