/** * INTERNAL: * Checks if the class is invloved in inheritence */ public boolean hasClassIndicator() { return getClassIndicatorField() != null; }
/** * PUBLIC: * Return the class indicator field name. * This is the name of the field in the table that stores what type of object this is. */ public String getClassIndicatorFieldName() { if (getClassIndicatorField() == null) { return null; } else { return getClassIndicatorField().getQualifiedName(); } }
/** * 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: * Clone the policy */ public Object clone() { InheritancePolicy clone = null; try { clone = (InheritancePolicy)super.clone(); if (hasClassIndicator()) { clone.setClassIndicatorField((DatabaseField)clone.getClassIndicatorField().clone()); } } catch (Exception exception) { throw new InternalError("clone failed"); } return clone; }
/** * 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 getClassIndicatorField() { if (m_accessor.getInheritanceParentDescriptor() != null) { return m_accessor.getInheritanceParentDescriptor().getClassDescriptor().getInheritancePolicy().getClassIndicatorField(); } else { if (getClassDescriptor().hasInheritance()) { return getClassDescriptor().getInheritancePolicy().getClassIndicatorField(); } else { return null; } } }
/** * 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())); } } }
throw QueryException.discriminatorColumnNotSelected(this.discriminatorColumn, query.getSQLResultSetMapping().getName()); entityRecord.put(descriptor.getInheritancePolicy().getClassIndicatorField(), record.get(this.discriminatorColumn)); }else{ entityRecord.put(descriptor.getInheritancePolicy().getClassIndicatorField(), record.get(descriptor.getInheritancePolicy().getClassIndicatorField()));
Object classFieldValue = session.getDatasourcePlatform().getConversionManager().convertObject(rowFromDatabase.get(getClassIndicatorField()), getClassIndicatorField().getType());
setClassIndicatorField(getParentDescriptor().getInheritancePolicy().getClassIndicatorField()); if ((getClassIndicatorField() == null) && (!hasClassExtractor())) { session.getIntegrityChecker().handleError(DescriptorException.classIndicatorFieldNotFound(getDescriptor(), getDescriptor())); if (getClassIndicatorField() != null) { getDescriptor().buildField(getClassIndicatorField()); getClassIndicatorField().setType(ClassConstants.STRING); } else if (!getClassIndicatorMapping(session.getDatasourcePlatform().getConversionManager()).isEmpty()) { Class type = null; getClassIndicatorField().setType(type); getDescriptor().getFields().addElement(getClassIndicatorField());
DatabaseField field = inheritancePolicy.getClassIndicatorField(); DataTable table = dataSet.getTable(field.getTableName()); DataRow row = getRow(rowMap, table);
/** * entityDescからInheritancePolicyを取得し、継承関連のカラムをdataSetに定義します。 */ protected void setupDiscriminatorColumn() { if (!getEntityDesc().hasDiscriminatorColumn()) { return; } InheritancePolicy inheritancePolicy = getEntityDesc().getInheritancePolicy(); DatabaseField field = inheritancePolicy.getClassIndicatorField(); DataTable table = dataSet.getTable(field.getTableName()); ServerSession serverSession = getEntityDesc().getServerSession(); DatabasePlatform platform = serverSession.getPlatform(); int sqlType = platform.getJDBCType(field); String columnName = field.getName(); if (!table.hasColumn(columnName)) { table.addColumn(columnName, ColumnTypes.getColumnType(sqlType)); } }
/** * INTERNAL: * Return a select statement that will be used to query the class indicators required to query. * This is used in the abstract-multiple read. */ public SQLSelectStatement buildClassIndicatorSelectStatement(ObjectLevelReadQuery query) { SQLSelectStatement selectStatement; selectStatement = new SQLSelectStatement(); selectStatement.useDistinct(); selectStatement.addTable(classIndicatorField.getTable()); selectStatement.addField(getClassIndicatorField()); // 2612538 - the default size of IdentityHashtable (32) is appropriate IdentityHashtable clonedExpressions = new IdentityHashtable(); selectStatement.setWhereClause(((ExpressionQueryMechanism)query.getQueryMechanism()).buildBaseSelectionCriteria(false, clonedExpressions)); appendWithAllSubclassesExpression(selectStatement); selectStatement.setTranslationRow(query.getTranslationRow()); selectStatement.normalize(query.getSession(), getDescriptor(), clonedExpressions); ExpressionQueryMechanism m = (ExpressionQueryMechanism)query.getQueryMechanism(); return selectStatement; }
DatabaseField typeField = getClassIndicatorField(); if (typeField == null) { throw DescriptorException.classIndicatorFieldNotFound(getParentDescriptor(), getDescriptor());