Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

I keep getting multiple joins when I use multiple anyOf( ) functions in my expression, which is returning too many results. How do I get it down to one join instead?

0
Posted

I keep getting multiple joins when I use multiple anyOf( ) functions in my expression, which is returning too many results. How do I get it down to one join instead?

0

Each time you use anyOf() in your expression, you get another join in your database. For example, the TopLink expression: emp.anyOf(“managedEmployees”).get(“lastName”).equal(“Smith”).and(emp.anyOf(“managedEmployees”).get(“firstName”).equal(“John”)); will return any Employee who manages a John or a Smith, not just John Smith. This is because a separate join is performed for each anyOf() . To force a single join, the same anyOf node must be used for each query: Expression managedEmployees = emp.anyOf(“managedEmployees”); … managedEmployees.get(“lastName”).equal(“Smith”).and(managedEmployees.get(“firstName”).

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123