/** * Initialize the query-based value holder. * @param query The query that returns the object when executed. * @param row The row representation of the object. * @param mapping The mapping that is uses batch reading. */ public BatchValueHolder(ReadQuery query, AbstractRecord row, ForeignReferenceMapping mapping, ObjectLevelReadQuery originalQuery, CacheKey parentCacheKey) { super(query, row, originalQuery.getSession()); this.mapping = mapping; this.originalQuery = originalQuery; this.parentCacheKey = parentCacheKey; }
/** * Initialize the query-based value holder. * @param query The query that returns the object when executed. * @param row The row representation of the object. * @param mapping The mapping that is uses batch reading. */ public BatchValueHolder(ReadQuery query, AbstractRecord row, ForeignReferenceMapping mapping, ObjectLevelReadQuery originalQuery, CacheKey parentCacheKey) { super(query, row, originalQuery.getSession()); this.mapping = mapping; this.originalQuery = originalQuery; this.parentCacheKey = parentCacheKey; }
/** * INTERNAL: * An object has been serialized from the server to the remote client. * Replace the transient attributes of the remote value holders * with client-side objects. */ protected void fixAttributeValue(Object attributeValue, Map objectDescriptors, Map processedObjects, ObjectLevelReadQuery query, DistributedSession session) { if (attributeValue == null) { return; } getObjectBuilder(attributeValue, query.getSession()).fixObjectReferences(attributeValue, objectDescriptors, processedObjects, query, session); }
/** * INTERNAL: * An object has been serialized from the server to the remote client. * Replace the transient attributes of the remote value holders * with client-side objects. */ protected void fixAttributeValue(Object attributeValue, Map objectDescriptors, Map processedObjects, ObjectLevelReadQuery query, RemoteSession session) { if (attributeValue == null) { return; } getObjectBuilder(attributeValue, query.getSession()).fixObjectReferences(attributeValue, objectDescriptors, processedObjects, query, session); }
/** * INTERNAL: * Return the value to be stored in the object's attribute. * This value is determined by the batchQuery. * In this case, extract the result from the query. */ public Object valueFromBatchQuery(ReadQuery batchQuery, AbstractRecord row, ObjectLevelReadQuery originalQuery, CacheKey parentCacheKey) { return getForeignReferenceMapping().extractResultFromBatchQuery(batchQuery, parentCacheKey, row, originalQuery.getSession(), originalQuery); }
/** * INTERNAL: * Return the value to be stored in the object's attribute. * This value is determined by the batchQuery. * In this case, extract the result from the query. */ public Object valueFromBatchQuery(ReadQuery batchQuery, AbstractRecord row, ObjectLevelReadQuery originalQuery, CacheKey parentCacheKey) { return getForeignReferenceMapping().extractResultFromBatchQuery(batchQuery, parentCacheKey, row, originalQuery.getSession(), originalQuery); }
/** * INTERNAL: * An object has been serialized from the server to the remote client. * Replace the transient attributes of the remote value holders * with client-side objects. */ protected void fixAttributeValue(Object attributeValue, Map objectDescriptors, Map processedObjects, ObjectLevelReadQuery query, DistributedSession session) { if (attributeValue == null) { return; } getObjectBuilder(attributeValue, query.getSession()).fixObjectReferences(attributeValue, objectDescriptors, processedObjects, query, session); }
/** * INTERNAL: * Return the selection criteria used to IN batch fetching. */ @Override protected Expression buildBatchCriteria(ExpressionBuilder builder, ObjectLevelReadQuery query) { int size = this.targetForeignKeyFields.size(); if (size > 1) { // Support composite keys using nested IN. List<Expression> fields = new ArrayList<Expression>(size); for (DatabaseField targetForeignKeyField : this.targetForeignKeyFields) { fields.add(builder.getField(targetForeignKeyField)); } return query.getSession().getPlatform().buildBatchCriteriaForComplexId(builder, fields); } else { return query.getSession().getPlatform().buildBatchCriteria(builder, builder.getField(this.targetForeignKeyFields.get(0))); } }
/** * INTERNAL: * Return the selection criteria used to IN batch fetching. */ public Expression buildBatchCriteriaByPK(ExpressionBuilder builder, ObjectLevelReadQuery query) { int size = getPrimaryKeyFields().size(); if (size > 1) { // Support composite keys using nested IN. List<Expression> fields = new ArrayList<Expression>(size); for (DatabaseField targetForeignKeyField : primaryKeyFields) { fields.add(builder.getField(targetForeignKeyField)); } return query.getSession().getPlatform().buildBatchCriteriaForComplexId(builder, fields); } else { return query.getSession().getPlatform().buildBatchCriteria(builder, builder.getField(primaryKeyFields.get(0))); } } /**
/** * INTERNAL: * Return the selection criteria used to IN batch fetching. */ @Override protected Expression buildBatchCriteria(ExpressionBuilder builder, ObjectLevelReadQuery query) { int size = this.referenceKeyFields.size(); Expression table = builder.getTable(this.referenceTable); if (size > 1) { // Support composite keys using nested IN. List<Expression> fields = new ArrayList<Expression>(size); for (DatabaseField referenceKeyField : this.referenceKeyFields) { fields.add(table.getField(referenceKeyField)); } return query.getSession().getPlatform().buildBatchCriteriaForComplexId(builder, fields); } else { return query.getSession().getPlatform().buildBatchCriteria(builder, table.getField(this.referenceKeyFields.get(0))); } }
/** * INTERNAL: * Return the selection criteria used to IN batch fetching. */ @Override protected Expression buildBatchCriteria(ExpressionBuilder builder, ObjectLevelReadQuery query) { int size = this.referenceKeyFields.size(); Expression table = builder.getTable(this.referenceTable); if (size > 1) { // Support composite keys using nested IN. List<Expression> fields = new ArrayList<Expression>(size); for (DatabaseField referenceKeyField : this.referenceKeyFields) { fields.add(table.getField(referenceKeyField)); } return query.getSession().getPlatform().buildBatchCriteriaForComplexId(builder, fields); } else { return query.getSession().getPlatform().buildBatchCriteria(builder, table.getField(this.referenceKeyFields.get(0))); } }
/** * INTERNAL: * Prepare the receiver for execution in a session. */ @Override protected void prepareForRemoteExecution() throws QueryException { super.prepareForRemoteExecution(); checkPrePrepare(getSession()); prepareQuery(); }
/** * INTERNAL: * Return the selection criteria used to IN batch fetching. */ public Expression buildBatchCriteriaByPK(ExpressionBuilder builder, ObjectLevelReadQuery query) { int size = getPrimaryKeyFields().size(); if (size > 1) { // Support composite keys using nested IN. List<Expression> fields = new ArrayList<Expression>(size); for (DatabaseField targetForeignKeyField : primaryKeyFields) { fields.add(builder.getField(targetForeignKeyField)); } return query.getSession().getPlatform().buildBatchCriteriaForComplexId(builder, fields); } else { return query.getSession().getPlatform().buildBatchCriteria(builder, builder.getField(primaryKeyFields.get(0))); } } /**
/** * INTERNAL: * Prepare the receiver for execution in a session. */ @Override protected void prepareForRemoteExecution() throws QueryException { super.prepareForRemoteExecution(); checkPrePrepare(getSession()); prepareQuery(); }
/** * INTERNAL: * Prepare the receiver for execution in a session. */ protected void prepareForRemoteExecution() throws QueryException { super.prepareForRemoteExecution(); checkPrePrepare(getSession()); prepareQuery(); }
/** * INTERNAL: * Return the value to be stored in the object's attribute. * This value is determined by the batchQuery. * In this case, extract the result from the query. */ public Object valueFromBatchQuery(ReadQuery batchQuery, AbstractRecord row, ObjectLevelReadQuery originalQuery) { return getForeignReferenceMapping().extractResultFromBatchQuery(batchQuery, row, originalQuery.getSession(), originalQuery.getTranslationRow()); }
/** * INTERNAL: * Return the descriptor for the base expression. This is used in ReportItem when building the * return value (a class), as none of the expressions will have a session. */ public ClassDescriptor getContainingDescriptor(ObjectLevelReadQuery query) { Class queryClass = null; if (getBaseExpression().isExpressionBuilder()){ queryClass = ((ExpressionBuilder)getBaseExpression()).getQueryClass(); return query.getSession().getDescriptor(queryClass); } else { // It must be a QueryKeyExpression. return getBaseExpression().getLeafDescriptor(query, query.getDescriptor(), query.getSession()); } }
/** * INTERNAL: * Return the descriptor for the base expression. This is used in ReportItem when building the * return value (a class), as none of the expressions will have a session. */ public ClassDescriptor getContainingDescriptor(ObjectLevelReadQuery query) { Class queryClass = null; if (getBaseExpression().isExpressionBuilder()){ queryClass = ((ExpressionBuilder)getBaseExpression()).getQueryClass(); return query.getSession().getDescriptor(queryClass); } else { // It must be a QueryKeyExpression. return getBaseExpression().getLeafDescriptor(query, query.getDescriptor(), query.getSession()); } }
/** * INTERNAL: * Return the descriptor for the base expression. This is used in ReportItem when building the * return value (a class), as none of the expressions will have a session. */ public ClassDescriptor getContainingDescriptor(ObjectLevelReadQuery query) { AbstractSession session; Class queryClass = null; if (getBaseExpression().isExpressionBuilder()){ queryClass = ((ExpressionBuilder)getBaseExpression()).getQueryClass(); return query.getSession().getDescriptor(queryClass); } else { //it must be a QueryKeyExpression return query.getLeafDescriptorFor(getBaseExpression(), query.getDescriptor()); } }
/** * INTERNAL: * Prepare the receiver for execution in a session. */ @Override protected void prepare() throws QueryException { super.prepare(); prepareQuery(); if (hasJoining()) { this.joinedAttributeManager.computeJoiningMappingQueries(session); } computeBatchReadMappingQueries(); if (getLoadGroup() != null) { if (getLoadGroup().getIsConcurrent() == null) { getLoadGroup().setIsConcurrent(getSession().isConcurrent()); } } }