Class Subquery

java.lang.Object
ubic.gemma.persistence.util.Subquery

public final class Subquery extends Object
Represents a subquery right-hand side of a Filter.

A subquery has rather limited structure:

select {rootAlias}.{propertyName} from {entityName} {rootAlias} join {aliases...} where {filters...}

and is solely designed to nest one or more Filter in a subquery so that they can be applied to one-to-many relations.

When more than one filter is carried they are conjoined, and the conjunction binds to a SINGLE element of the relation. That is the difference that makes this type worth having: two separate subqueries ask "some characteristic has X" AND "some characteristic has Y", whereas one subquery over two filters asks "some characteristic has X AND Y". Only the latter can express "this gene URI, as a genotype".

The root alias is used whenever null is used as object alias in the aliases or filter. It can be declared by passing an Subquery.Alias with a null object alias and an empty property name.

Author:
poirgui
See Also:
  • Constructor Details

  • Method Details

    • getFilter

      public Filter getFilter()
      The sole filter carried by this subquery.
      Throws:
      IllegalStateException - if this subquery carries a conjunction; callers that can encounter one must read getFilters() and handle every conjunct.
    • withFilterPropertyName

      public Subquery withFilterPropertyName(String newPropertyName, @Nullable String originalProperty)
      Create a new subquery with a different property name for the filters.
    • toString

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

      public String getEntityName()
      The entity name being queried.
    • getPropertyName

      public String getPropertyName()
      The property name being queried.
    • getAliases

      public List<Subquery.Alias> getAliases()
      List of aliases for resolving the object alias defined in filter.
    • getRootAlias

      public String getRootAlias()
      Root alias of this subquery.

      If none are defined in aliases, the default e is used.

    • getFilters

      public List<Filter> getFilters()
      The filters being nested in the subquery, conjoined. Never empty.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object