Class QueryObjectPathExpression

  • All Implemented Interfaces:
    Queryable, QueryPathExpression, QueryPathExpressionWithSelect, QuerySelectable

    public class QueryObjectPathExpression
    extends java.lang.Object
    implements QueryPathExpressionWithSelect, Queryable
    An element that can appear in the SELECT clause of a query, representing extra data to be collected for the Results - namely a object referenced by some other object in the results. In order to reference further into this reference, this class contains many of the features of Query. That is, you can add QueryFields and QueryPathExpressions to the SELECT list. You can also add QueryClasses to the FROM list and constraints to the WHERE clause. A default QueryClass corresponding to the reference is available from the getDefaultClass method. Counter-intuitively, this path expression may return multiple rows per original row, if extra things are added to the FROM list for example. In this case, this object should be on the SELECT list of the original Query. In the case where this object is guaranteed to return a maximum of one row per original row, then PathExpressionField objects should be put in the SELECT list of the original query instead. The definition is that if this object contains anything in the FROM element, then we cannot guarantee that it will only have one row per original row.
    Author:
    Matthew Wakeling
    • Constructor Summary

      Constructors 
      Constructor Description
      QueryObjectPathExpression​(QueryClass qc, java.lang.String fieldName)
      Constructs a QueryObjectPathExpression representing an object reference from the given QueryClass to the given fieldname.
      QueryObjectPathExpression​(QueryClass qc, java.lang.String fieldName, java.lang.Class<?>... subclasses)
      Constructs a QueryObjectPathExpression representing an object reference from the given QueryClass to the given fieldname, constrained to be a particular subclass.
    • Constructor Detail

      • QueryObjectPathExpression

        public QueryObjectPathExpression​(QueryClass qc,
                                         java.lang.String fieldName)
        Constructs a QueryObjectPathExpression representing an object reference from the given QueryClass to the given fieldname.
        Parameters:
        qc - the QueryClass of the starting class
        fieldName - the name of field in qc we want to perform an outer join on
        Throws:
        java.lang.IllegalArgumentException - if the field is not an object reference
      • QueryObjectPathExpression

        public QueryObjectPathExpression​(QueryClass qc,
                                         java.lang.String fieldName,
                                         java.lang.Class<?>... subclasses)
        Constructs a QueryObjectPathExpression representing an object reference from the given QueryClass to the given fieldname, constrained to be a particular subclass.
        Parameters:
        qc - the QueryClass
        fieldName - the name of the relevant field
        subclasses - a Class that is a subclass of the field class
        Throws:
        java.lang.IllegalArgumentException - if the field is not an object reference
    • Method Detail

      • getFieldName

        public java.lang.String getFieldName()
        Returns the name of the field.
        Returns:
        field name
      • getSubclass

        public java.lang.Class<? extends FastPathObject> getSubclass()
        Returns the subclass if it exists.
        Returns:
        the subclass
      • getType

        public java.lang.Class<?> getType()
        Get Java type represented by this item.
        Specified by:
        getType in interface QuerySelectable
        Returns:
        class describing the type
      • getDefaultClass

        public QueryClass getDefaultClass()
        Returns the QueryClass that represents the collection in this object.
        Returns:
        a QueryClass
      • setConstraint

        public void setConstraint​(Constraint c)
        Sets the additional constraint.
        Specified by:
        setConstraint in interface Queryable
        Parameters:
        c - a Constraint
      • getConstraint

        public Constraint getConstraint()
        Returns the additional constraint.
        Specified by:
        getConstraint in interface Queryable
        Returns:
        a Constraint
      • getQuery

        public Query getQuery​(java.util.Collection<java.lang.Integer> bag,
                              boolean isNoNotXml)
        Returns the Query that will fetch the data represented by this object, given a Collection of objects to fetch it for.
        Parameters:
        bag - a Collection of objects to fetch data for, or null to not constrain
        isNoNotXml - true if the database is in missingNotXml mode
        Returns:
        a Query