Class RetrieveDescImpl

    • Field Detail

      • OPT_PROJECTION

        public static final int OPT_PROJECTION
        Indicates, that the query projects on this RD.
        See Also:
        Constant Field Values
      • OPT_DISTINCT

        public static final int OPT_DISTINCT
        Indicates, that a distinct query should be run.
        See Also:
        Constant Field Values
      • OPT_FOR_UPDATE

        public static final int OPT_FOR_UPDATE
        Indicates, that the selected rows should be locked for update.
        See Also:
        Constant Field Values
      • OPT_AVG

        public static final int OPT_AVG
        Indicates, that an avg aggregate query should be run.
        See Also:
        Constant Field Values
      • OPT_MIN

        public static final int OPT_MIN
        Indicates, that a min aggregate query should be run.
        See Also:
        Constant Field Values
      • OPT_MAX

        public static final int OPT_MAX
        Indicates, that a max aggregate query should be run.
        See Also:
        Constant Field Values
      • OPT_SUM

        public static final int OPT_SUM
        Indicates, that a sum aggregate query should be run.
        See Also:
        Constant Field Values
      • OPT_COUNT

        public static final int OPT_COUNT
        Indicates, that a count aggregate query should be run.
        See Also:
        Constant Field Values
      • OPT_COUNT_PC

        public static final int OPT_COUNT_PC
        Special treatment for count on persistent capable objects.
        See Also:
        Constant Field Values
      • OPT_AGGREGATE

        public static final int OPT_AGGREGATE
        Sum of all aggregate options.
        See Also:
        Constant Field Values
      • OPT_AGGREGATE_NON_COUNT_PC

        public static final int OPT_AGGREGATE_NON_COUNT_PC
        Sum of all aggregate options excluding count on persistent capable objects.
        See Also:
        Constant Field Values
      • OPT_ADD_FETCHGROUPS

        public static final int OPT_ADD_FETCHGROUPS
        Indicates, that fetch group fields should be added.
        See Also:
        Constant Field Values
      • OPT_ADD_KEYS_ONLY

        public static final int OPT_ADD_KEYS_ONLY
        Indicates, that only key fields should be added. When this option is set, it modifies meaning of OPT_ADD_FETCHGROUPS. It is assumed that only key fieldes from the fetch group will be added.
        See Also:
        Constant Field Values
      • OPT_DISABLE_RELATIONSHIP_PREFETCH

        public static final int OPT_DISABLE_RELATIONSHIP_PREFETCH
        Indicates, that even if relationship fields are in DFG, they should not be prefetched. The runtime will attempt to fetch relationhip fields only when OPT_ADD_FETCH_GROUPS is set.
        See Also:
        OPT_ADD_FETCHGROUPS, OPT_ADD_KEYS_ONLY, Constant Field Values
      • OPT_VERIFY

        public static final int OPT_VERIFY
        Indicates special treatment for version consistency verifications.
        See Also:
        Constant Field Values
    • Constructor Detail

      • RetrieveDescImpl

        public RetrieveDescImpl​(Class pcClass,
                                ClassDesc config)
    • Method Detail

      • addResult

        public void addResult​(String name,
                              RetrieveDesc foreignConstraint,
                              boolean projection)
        The addResult method is used to specify which fields should be returned in a persistent object. If the field requested is a reference to another persistent object then a RetrieveDesc may be provided which describes which fields of the referenced object should be returned and, optionally, constraints on it. If the parameter projection is true, the field specified by name should be projected.
        Specified by:
        addResult in interface RetrieveDesc
        Parameters:
        name - The name of the field to return.
        foreignConstraint - RetrieveDesc describing fields and constraints for a referenced object.
        projection - Specifies, if this is a projection.
      • addResult

        public void addResult​(int opCode,
                              int aggregateResultType)
        The addResult method can be used to specify global query attributes that don't end up in the where clause. Aggregate functions and the distinct op code are examples for those query options. The result type defines the object to be returned by an aggregate query. In case of distinct the result type should be FieldTypeEnumeration.NOT_ENUMERATED. The method might be called twice, in case of a JDOQL query having both an aggregate and distinct: query.setResult("avg (distinct salary)"); -> retrieveDesc.addResult(OP_AVG, FieldTypeEnumeration.DOUBLE); retrieveDesc.addResult(OP_DISTINCT, FieldTypeEnumeration.NOT_ENUMERATED); retrieveDesc.addResult("salary", null, true);
        Specified by:
        addResult in interface RetrieveDesc
        Parameters:
        opCode - The operation code.
        aggregateResultType - The object type returned by aggregate queries.
        See Also:
        FieldTypeEnumeration
      • addPrefetchedField

        public void addPrefetchedField​(String name,
                                       RetrieveDesc foreignConstraint)
        Add a field specified by name to the list of fields to be prefetched.
        Parameters:
        name - Name of the field to be prefetched.
        foreignConstraint - This parameter is null if the field is a local field. If the field is a foreign field, this parameter should be not null and must refer to an instance of RetrieveDesc correpsonding to the config of the foreign field.
      • setPrefetchEnabled

        public void setPrefetchEnabled​(boolean prefetchEnabled)
        Sets the prefetchEnabled option. The prefetchEnabled option specifies whether prefetch of relationship fields should be enabled for this retrieve descriptor. The prefetch is enabled by default if such fields are part of DFG. A user needs to explicitely disable prefetch for any particular query if the related instances will not be used in this transaction.
        Specified by:
        setPrefetchEnabled in interface RetrieveDesc
        Parameters:
        prefetchEnabled - the setting of the prefetchEnabled option.
      • addConstraint

        public void addConstraint​(String name,
                                  RetrieveDesc foreignConstraint)

        Adds a constraint on the foreign field specified by name. This method is used to specify a relationship navigation on field name to the class represented by the retrieve descriptor foreignConstraint. If name is null, an unrelated constraint is added. A constraint is unrelated, if there is neither a foreign field nor a local field connecting to the retrieve descriptor foreignConstraint.

        Specified by:
        addConstraint in interface RetrieveDesc
      • addConstraint

        public void addConstraint​(String name,
                                  int operation,
                                  RetrieveDesc foreignConstraint,
                                  String foreignName)

        Adds a constraint on the relationship field specified by name. This method is useful e.g. for comparisons of local fields with field of a related object: emp.addConstraint("lastName", ActionDesc.OP_EQ, mgr, lastName"); compares the employee's lastName field with the lastName field of the related manager.

        Specified by:
        addConstraint in interface RetrieveDesc
      • addConstraint

        public void addConstraint​(String name,
                                  int operation,
                                  Object value)
        The addConstraint method is used to limit the values of fields for objects being selected. addConstraint pushes the value, name, and operation onto the Constraint stack. The constraints are anded together by default. Arbitrarily complex relationships on the Constraint stack are supported. The Constraint stack can be manipulated directly if necessary.
        Specified by:
        addConstraint in interface RetrieveDesc
        Parameters:
        name - The name parameter specifies the field whose value should be limited.
        operation - The operation parameter specifies the relationship the field should bear to the value. Values for operation are defined in the ActionDesc interface.
        value - The value parameter usually specifies the value to which the field should be limited, however it is sometimes used to hold a parameter count as for the OP_IN operation.
      • addParameterConstraints

        public void addParameterConstraints​(LocalFieldDesc[] fields,
                                            int startIndex)
        Add Constraints corresponding to given fields. The constraints are added as Parameter Constraints. index of the parameter starts at given startIndex
        Parameters:
        fields - fields for which constraints are to be added.
        startIndex - starting Index for the parameter.
      • addParameterConstraint

        public void addParameterConstraint​(LocalFieldDesc field,
                                           int index)
        Add ParameterConstraint corresponding to given field at given index.
        Parameters:
        field - The field for which constraints are to be added.
        index - Index at which the ParameterConstraint is to be inserted.
      • setNavigationalId

        public void setNavigationalId​(Object navigationalId)
        Sets a navigational id on the retrieve descriptor. This id will be used to discriminate different retrieve descriptors which use the same navigational field. If not set, the field name is used.
        Specified by:
        setNavigationalId in interface RetrieveDesc
        Parameters:
        navigationalId - Tag to discriminate different retrieve descriptors that use the same navigational field.
      • getNavigationalId

        public Object getNavigationalId()
        Returns the navigational id of this retrieve descriptor. This id will be used to discriminate different retrieve descriptors which use the same navigational field. If not set, the field name is used.
        Returns:
        Tag to discriminate different retrieve descriptors that use the same navigational field.
      • setOption

        public void setOption​(int option)
        Sets option option. Only used to mark this retrieve descriptor as internal. All valid options are defined in this class.
        Parameters:
        option - Option being set.
      • getAggregateResultType

        public int getAggregateResultType()
        Returns the result type for aggregate queries.
      • getOptions

        public int getOptions()
        Returns the options of this retrieve descriptor.
        Returns:
        The options of this retrieve descriptor.
      • getConstraint

        public Constraint getConstraint()
      • getFields

        public Iterator getFields()