use of com.sun.jdo.spi.persistence.support.sqlstore.sql.constraint.ConstraintFieldName in project Payara by payara.
the class RetrieveDescImpl method addResult.
/**
* 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 <code>projection</code> is true, the field
* specified by <code>name</code> should be projected.
*
* @param name The name of the field to return.
* @param foreignConstraint
* RetrieveDesc describing fields and constraints for a referenced object.
* @param projection Specifies, if this is a projection.
*/
public void addResult(String name, RetrieveDesc foreignConstraint, boolean projection) {
ConstraintFieldName cfName = new ConstraintFieldName(name, foreignConstraint);
if (projection) {
if ((options & OPT_PROJECTION) > 0) {
throw new JDOFatalInternalException(I18NHelper.getMessage(messages, // NOI18N
"sqlstore.retrievedesc.toomanyprojections"));
}
// For local fields, set the property on the field constraint.
if (foreignConstraint != null) {
((RetrieveDescImpl) foreignConstraint).options |= OPT_PROJECTION;
} else {
cfName.setProjection();
// Set this property if you want to have DFG fields added for
// projections on local fields.
// options = options | OPT_PROJECTION;
}
}
fields.add(cfName);
}
use of com.sun.jdo.spi.persistence.support.sqlstore.sql.constraint.ConstraintFieldName in project Payara by payara.
the class RetrieveDescImpl method distributeQueryOptions.
/**
* Marks each descriptor with the options <code>queryOptions</code> and
* finds the projection in the retrieve descriptor hierarchy.
* The query options have to be known for each descriptor, because we don't want to
* generate outer joins for OPT_COUNT_PC and we want to propagate users
* choice to disable prefetch for a finder to projected RetrieveDesc.
* This method relies on the fact, that each query can have only
* <b>one</b> projection.
*
* @param queryOptions The options that need to be set on all
* retrieve descriptors. This helps identify aggregate queries, see
* {@link SelectQueryPlan#processJoins()}.
* This also helps propagate user's choice to disable prefetch to the
* projected RetrieveDesc, see
* {@link SelectQueryPlan#addFetchGroup(int, java.util.ArrayList, java.util.ArrayList)}.
* @param aggregateResultType The aggregate result type has to
* be set on the projected retrieve descriptor.
* @return The projected retrieve descriptor, or null there is
* no projection.
*/
private RetrieveDescImpl distributeQueryOptions(int queryOptions, int aggregateResultType) {
RetrieveDescImpl projectedDesc = null;
if ((options & OPT_PROJECTION) > 0) {
// This is a foreign field projection.
// Set the fetch group properties.
setFetchGroupOptions(queryOptions);
this.aggregateResultType = aggregateResultType;
projectedDesc = this;
}
// Distribute the aggregate option to all retrieve descriptors.
options |= queryOptions;
// Loop through all dependent retrieve descriptors in the field list.
for (int i = 0; i < fields.size(); i++) {
ConstraintFieldName cfn = (ConstraintFieldName) fields.get(i);
if (cfn.isProjection()) {
// This is a local field projection.
// No fetch groups are added.
this.aggregateResultType = aggregateResultType;
projectedDesc = this;
} else if (cfn.desc != null) {
projectedDesc = ((RetrieveDescImpl) cfn.desc).distributeQueryOptions(queryOptions, aggregateResultType);
}
}
return projectedDesc;
}
Aggregations