Interface RetrieveDesc
-
- All Superinterfaces:
ActionDesc
- All Known Implementing Classes:
RetrieveDescImpl
public interface RetrieveDesc extends ActionDesc
This interface represents a retrieve descriptor used by an application to retrieve container-managed entity beans from a persistent store. It allows you specify which persistent fields an application wants to retrieve. In addition, it allows an application to specify sophisticated constraints on its object retrieval.
-
-
Field Summary
-
Fields inherited from interface com.sun.jdo.spi.persistence.support.sqlstore.ActionDesc
LOG_CREATE, LOG_DESTROY, LOG_NOOP, LOG_UPDATE, OP_ABS, OP_ADD, OP_AND, OP_APPROX, OP_AVG, OP_BETWEEN, OP_CONCAT, OP_COUNT, OP_COUNT_PC, OP_DISTINCT, OP_DIV, OP_EQ, OP_EQ_CLASS, OP_EQUIJOIN, OP_EXISTS, OP_FIELD, OP_FOR_UPDATE, OP_GE, OP_GT, OP_IN, OP_LE, OP_LEFTJOIN, OP_LENGTH, OP_LENGTHB, OP_LIKE, OP_LIKE_ESCAPE, OP_LOWER, OP_LT, OP_LTRIM, OP_MAX, OP_MAX_ROWS, OP_MAYBE_NULL, OP_MIN, OP_MOD, OP_MUL, OP_NE, OP_NONKEY, OP_NONREL_JOIN, OP_NOT, OP_NOTEXISTS, OP_NOTIN, OP_NOTNULL, OP_NULL, OP_NULL_COMPARISION_FUNCTION, OP_OR, OP_ORDERBY, OP_ORDERBY_DESC, OP_PARAMETER, OP_PARAMETER_COUNT, OP_POSITION, OP_POSITION_START, OP_RIGHTJOIN, OP_RTRIM, OP_RTRIMFIXED, OP_SOUNDEX, OP_SQRT, OP_SUB, OP_SUBSTR, OP_SUBSTRB, OP_SUBSTRING, OP_SUM, OP_UPPER, OP_VALUE
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addConstraint(String name, int operator, RetrieveDesc foreignConstraint, String foreignFieldName)
Adds a constraint on the field specified byname
.void
addConstraint(String name, int operation, Object value)
Adds a constraint on the persistent field specified byname
.void
addConstraint(String name, RetrieveDesc foreignConstraint)
Adds a constraint on the foreign field specified byname
.void
addResult(int opCode, int resultType)
The addResult method can be used to specifyglobal query attributes that don't end up in the where clause.void
addResult(String name, RetrieveDesc foreignConstraint, boolean projection)
The addResult method is used to specify which fields should be returned in a persistent object.void
setNavigationalId(Object navigationalId)
Sets a navigational id on the retrieve descriptor.void
setPrefetchEnabled(boolean prefetchEnabled)
Sets the prefetchEnabled option.-
Methods inherited from interface com.sun.jdo.spi.persistence.support.sqlstore.ActionDesc
getPersistenceCapableClass
-
-
-
-
Method Detail
-
addResult
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. The parameterprojection
specifies, if the field specified byname
should be projected.- 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
void addResult(int opCode, int resultType)
The addResult method can be used to specifyglobal 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);- Parameters:
opCode
- The operation code.resultType
- The object type returned by aggregate queries.- See Also:
FieldTypeEnumeration
-
addConstraint
void addConstraint(String name, int operation, Object value)
Adds a constraint on the persistent field specified by
name
. The valid values foroperation
are defined in ActionDesc. The parametervalue
specifies the constraint value.By default, multiple constraints are implicitly ANDed together. If the applications want to OR together the constraints, it can explicitly add OP_OR constraints. For example, to OR together two constraints, an application can do the following:
addConstraint("field1", ActionDesc.OP_EQ, "field1Value"); addConstraint("field2", ActionDesc.OP_EQ, "field2Value"); addConstraint(null, ActionDesc.OP_OR, null);
The important thing to note about the above example is that the constraints are processed in postfix order, so the above example should be read as
(field1 == "field1Value") OR (field2 == "field2Value")
-
addConstraint
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 fieldname
to the class represented by the retrieve descriptorforeignConstraint
. Ifname
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 descriptorforeignConstraint
.
-
addConstraint
void addConstraint(String name, int operator, RetrieveDesc foreignConstraint, String foreignFieldName)
Adds a constraint on the 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.
-
setNavigationalId
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.
-
setPrefetchEnabled
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.- Parameters:
prefetchEnabled
- the setting of the prefetchEnabled option.
-
-