0

Writing request that fetches all document entities that match different criteria I have two requests that work and each of them return some results that are completely different: First:

def documents = Document.withCriteria {
            pproperty{
                user{
                    idEq uuser.id
                }
            };
    }

Second:

def documents = Document.withCriteria {
            loan{
                bank{
                    user{
                    idEq uuser.id
                    }
                }
            }

    }

I'm trying to get the result of two in one query:

 def documents = Document.withCriteria {
        or {
           pproperty{
                user{
                    idEq uuser.id
                }
            };
            loan{
                bank{
                    user{
                    idEq uuser.id
                    }
                }
            }
        }

    }

And I get an empty result set. What's wring with queries or it's a grails bug?

tim_yates
  • 167,322
  • 27
  • 342
  • 338
Nikita
  • 194
  • 3
  • 10
  • If you can reproduce that behavior in a sample app file a JIRA at https://jira.grails.org/browse/GRAILS and we will get it straight. I expect there is something wrong in your code like curly braces not being matched up the way you intend, but if it really is a bug we can straighten it out. – Jeff Scott Brown Jul 02 '14 at 00:40
  • I tried the same thing with HQL : return Document.findAll(" from Document d where d.pproperty.user = :user or d.loan.bank.user = :user or account.bank.user=:user",[user:uuser]) and it's the same. each OR part works in separate query but not all in one – Nikita Jul 02 '14 at 01:52
  • If you can reproduce it in a sample app, please file a JIRA. – Jeff Scott Brown Jul 02 '14 at 02:04
  • One thing that might help is set `logSql = true` in DataSource.groovy and inspect the generated SQL. – Jeff Scott Brown Jul 02 '14 at 02:06

0 Answers0