Package com.axelor.db

Class Query.JoinHelper

java.lang.Object
com.axelor.db.Query.JoinHelper
Enclosing class:
Query<T extends Model>

protected static class Query.JoinHelper extends Object
JoinHelper class is used to auto generate LEFT JOIN for association expressions.

For example:

    Query<Contact> q = Contact.all().filter("self.title.code = ?1 OR self.age > ?2", "mr", 20);
 
Results in:
 SELECT self FROM Contact self LEFT JOIN self.title _title WHERE _title.code = ?1 OR self.age > ?2
 
So that all the records are matched even if title field is null.
  • Constructor Details

    • JoinHelper

      public JoinHelper(Class<?> beanClass)
  • Method Details

    • parse

      public String parse(String filter, boolean translate)
      Parse the given filter string and return transformed filter expression.

      Automatically calculate LEFT JOIN for association path expressions and the path expressions are replaced with the join variables.

      Parameters:
      filter - the filter expression
      translate - whether to generate translation join
      Returns:
      the transformed filter expression
    • joinName

      public String joinName(String name)
    • fixSelect

      public String fixSelect(String query)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toString

      public String toString(boolean fetch)