/** * INTERNAL: * Select one row of any concrete subclass, * This must use two selects, the first retrieves the type field only. */ public AbstractRecord selectOneRowUsingMultipleTableSubclassRead(ReadObjectQuery query) throws DatabaseException, QueryException { if (hasClassExtractor()) { return selectOneRowUsingCustomMultipleTableSubclassRead(query); } else { return selectOneRowUsingDefaultMultipleTableSubclassRead(query); } }
/** * INTERNAL: * Select one row of any concrete subclass, * This must use two selects, the first retrieves the type field only. */ public AbstractRecord selectOneRowUsingMultipleTableSubclassRead(ReadObjectQuery query) throws DatabaseException, QueryException { if (hasClassExtractor()) { return selectOneRowUsingCustomMultipleTableSubclassRead(query); } else { return selectOneRowUsingDefaultMultipleTableSubclassRead(query); } }
/** * INTERNAL: * Select all rows from a abstract table descriptor. * This is accomplished by selecting for all of the concrete classes and then merging the rows. * @return vector containing database rows. * @exception DatabaseException - an error has occurred on the database. */ public Vector selectAllRowUsingMultipleTableSubclassRead(ReadAllQuery query) throws DatabaseException { if (hasClassExtractor()) { return selectAllRowUsingCustomMultipleTableSubclassRead(query); } else { return selectAllRowUsingDefaultMultipleTableSubclassRead(query); } }
/** * INTERNAL: * Select one row of any concrete subclass, * This must use two selects, the first retrieves the type field only. */ public AbstractRecord selectOneRowUsingMultipleTableSubclassRead(ReadObjectQuery query) throws DatabaseException, QueryException { if (hasClassExtractor()) { return selectOneRowUsingCustomMultipleTableSubclassRead(query); } else { return selectOneRowUsingDefaultMultipleTableSubclassRead(query); } }
/** * INTERNAL: * Add abstract class indicator information to the database row. This is * required when building a row for an insert or an update of a concrete child * descriptor. * This is only used to build a template row. */ public void addClassIndicatorFieldToInsertRow(AbstractRecord databaseRow) { if (hasClassExtractor()) { return; } DatabaseField field = getClassIndicatorField(); databaseRow.put(field, null); }
/** * INTERNAL: * Add abstract class indicator information to the database row. This is * required when building a row for an insert or an update of a concrete child * descriptor. * This is only used to build a template row. */ public void addClassIndicatorFieldToInsertRow(AbstractRecord databaseRow) { if (hasClassExtractor()) { return; } DatabaseField field = getClassIndicatorField(); databaseRow.put(field, null); }
/** * INTERNAL: * Select all rows from a abstract table descriptor. * This is accomplished by selecting for all of the concrete classes and then merging the rows. * @return vector containing database rows. * @exception DatabaseException - an error has occurred on the database. */ public Vector selectAllRowUsingMultipleTableSubclassRead(ObjectLevelReadQuery query) throws DatabaseException { if (hasClassExtractor()) { return selectAllRowUsingCustomMultipleTableSubclassRead(query); } else { return selectAllRowUsingDefaultMultipleTableSubclassRead(query); } }
/** * INTERNAL: * Select all rows from a abstract table descriptor. * This is accomplished by selecting for all of the concrete classes and then merging the rows. * @return vector containing database rows. * @exception DatabaseException - an error has occurred on the database. */ public Vector selectAllRowUsingMultipleTableSubclassRead(ObjectLevelReadQuery query) throws DatabaseException { if (hasClassExtractor()) { return selectAllRowUsingCustomMultipleTableSubclassRead(query); } else { return selectAllRowUsingDefaultMultipleTableSubclassRead(query); } }
/** * INTERNAL: * Add abstract class indicator information to the database row. This is * required when building a row for an insert or an update of a concrete child * descriptor. */ public void addClassIndicatorFieldToRow(AbstractRecord databaseRow) { if (hasClassExtractor()) { return; } DatabaseField field = getClassIndicatorField(); Object value = getClassIndicatorValue(); databaseRow.put(field, value); }
/** * INTERNAL: * Add abstract class indicator information to the database row. This is * required when building a row for an insert or an update of a concrete child * descriptor. */ public void addClassIndicatorFieldToRow(AbstractRecord databaseRow) { if (hasClassExtractor()) { return; } DatabaseField field = getClassIndicatorField(); Object value = getClassIndicatorValue(); databaseRow.put(field, value); }
/** * INTERNAL: * Add abstract class indicator information to the database row. This is * required when building a row for an insert or an update of a concrete child * descriptor. */ public void addClassIndicatorFieldToRow(AbstractRecord databaseRow) { if (hasClassExtractor()) { return; } DatabaseField field = getClassIndicatorField(); Object value = getClassIndicatorValue(); databaseRow.put(field, value); }
/** * INTERNAL: */ public DatabaseField getField() { if (field == null) { ClassDescriptor descriptor = getContainingDescriptor(); if (!descriptor.hasInheritance() || descriptor.getInheritancePolicy().hasClassExtractor()){ throw QueryException.invalidTypeExpression(descriptor.getJavaClassName()); } field = descriptor.getInheritancePolicy().getClassIndicatorField(); } return field; }
/** * INTERNAL * This method returns the inheritance field value for an object to conform in an in-memory query. * Similar to getFieldValue, but deals with an instance rather than a Class object directly */ public Object typeValueFromObject(Object object, AbstractSession session) { // get the descriptor directly from the object, and use it to find the Java class ClassDescriptor objectDescriptor = session.getClassDescriptor(object); if (!objectDescriptor.hasInheritance() || objectDescriptor.getInheritancePolicy().shouldUseClassNameAsIndicator() || objectDescriptor.getInheritancePolicy().hasClassExtractor() ) { return (objectDescriptor.getJavaClassName()); } else { return objectDescriptor.getInheritancePolicy().getClassIndicatorMapping().get(objectDescriptor.getJavaClass()); } }
/** * INTERNAL: */ @Override public DatabaseField getField() { if (field == null) { ClassDescriptor descriptor = getContainingDescriptor(); if (!descriptor.hasInheritance() || descriptor.getInheritancePolicy().hasClassExtractor()){ throw QueryException.invalidTypeExpression(descriptor.getJavaClassName()); } field = descriptor.getInheritancePolicy().getClassIndicatorField(); } return field; }
/** * INTERNAL: */ public DatabaseField getField() { if (field == null) { ClassDescriptor descriptor = getContainingDescriptor(); if (!descriptor.hasInheritance() || descriptor.getInheritancePolicy().hasClassExtractor()){ throw QueryException.invalidTypeExpression(descriptor.getJavaClassName()); } field = descriptor.getInheritancePolicy().getClassIndicatorField(); } return field; }
/** * INTERNAL: * Initialize the expression to use for queries to the class and its subclasses. */ protected void initializeWithAllSubclassesExpression() throws DescriptorException { if (getWithAllSubclassesExpression() == null) { if (hasClassExtractor()) { return; } if (isChildDescriptor() && shouldReadSubclasses()) { setWithAllSubclassesExpression(new ExpressionBuilder().getField(getClassIndicatorField()).in(getAllChildClassIndicators())); } } }
/** * INTERNAL: * Initialize the expression to use for queries to the class and its subclasses. */ protected void initializeWithAllSubclassesExpression() throws DescriptorException { if (getWithAllSubclassesExpression() == null) { if (hasClassExtractor()) { return; } if (isChildDescriptor() && shouldReadSubclasses()) { setWithAllSubclassesExpression(new ExpressionBuilder().getField(getClassIndicatorField()).in(getAllChildClassIndicators())); } } }
/** * INTERNAL: * Initialize the expression to use for queries to the class and its subclasses. */ protected void initializeWithAllSubclassesExpression() throws DescriptorException { if (getWithAllSubclassesExpression() == null) { if (hasClassExtractor()) { return; } if (isChildDescriptor() && shouldReadSubclasses()) { setWithAllSubclassesExpression(new ExpressionBuilder().getField(getClassIndicatorField()).in(getAllChildClassIndicators())); } } }
/** * INTERNAL: * This method is invoked only for the abstract descriptors. */ @Override public Class classFromRow(AbstractRecord rowFromDatabase, AbstractSession session) throws DescriptorException { if (hasClassExtractor()) { return getClassExtractor().extractClassFromRow(rowFromDatabase, session); } Object classFieldValue = session.getDatasourcePlatform().getConversionManager().convertObject(rowFromDatabase.get(getClassIndicatorField()), getClassIndicatorField().getType()); if (classFieldValue == null) { throw DescriptorException.missingClassIndicatorField(rowFromDatabase, getDescriptor()); } return classFromValue(classFieldValue, session); }
/** * INTERNAL: * Indicates whether the query can use ResultSet optimization. * The method is called when the query is prepared, * so it should refer only to the attributes that cannot be altered without re-preparing the query. * If the query is a clone and the original has been already prepared * this method will be called to set a (transient and therefore set to null) usesResultSetAccessOptimization attribute. */ public boolean supportsResultSetAccessOptimizationOnPrepare() { DatabaseCall call = getCall(); return ((call != null) && call.getReturnsResultSet()) && // must return ResultSet (!hasJoining() || !this.joinedAttributeManager.isToManyJoin()) && (!this.descriptor.hasInheritance() || !this.descriptor.getInheritancePolicy().hasClassExtractor() && // ClassExtractor requires the whole row (shouldOuterJoinSubclasses() || !this.descriptor.getInheritancePolicy().requiresMultipleTableSubclassRead() || this.descriptor.getInheritancePolicy().hasView())) && // don't know how to handle select class type call - ResultSet optimization breaks it. (this.batchFetchPolicy == null || !this.batchFetchPolicy.isIN()); // batchFetchPolicy.isIN() requires all rows up front - can't support it }