/** * INTERNAL: * Return the relation table associated with the mapping. */ public DatabaseTable getRelationTable() { return this.mechanism.getRelationTable(); }
/** * PUBLIC: * Return RelationTable. */ public DatabaseTable getRelationTable() { if(this.mechanism != null) { return this.mechanism.getRelationTable(); } else { return null; } }
/** * PUBLIC: * Return RelationTable. */ public DatabaseTable getRelationTable() { if(this.mechanism != null) { return this.mechanism.getRelationTable(); } else { return null; } }
/** * PUBLIC: * Return RelationTable. */ public DatabaseTable getRelationTable() { if(this.mechanism != null) { return this.mechanism.getRelationTable(); } else { return null; } }
/** * INTERNAL: * Return the relation table associated with the mapping. */ public DatabaseTable getRelationTable() { return this.mechanism.getRelationTable(); }
/** * INTERNAL: * Return the relation table associated with the mapping. */ public DatabaseTable getRelationTable() { return this.mechanism.getRelationTable(); }
/** * INTERNAL: * All the source relation key field names are converted to DatabaseField and stored. */ protected void initializeSourceRelationKeys(AbstractSession session, ForeignReferenceMapping mapping) throws DescriptorException { if (getSourceRelationKeyFields().size() == 0) { throw DescriptorException.noSourceRelationKeysSpecified(mapping); } for (Enumeration entry = getSourceRelationKeyFields().elements(); entry.hasMoreElements();) { DatabaseField field = (DatabaseField)entry.nextElement(); if (field.hasTableName() && (!(field.getTableName().equals(getRelationTable().getName())))) { throw DescriptorException.relationKeyFieldNotProperlySpecified(field, mapping); } field.setTable(getRelationTable()); } }
/** * INTERNAL: * All the target relation key field names are converted to DatabaseField and stored. */ protected void initializeTargetRelationKeys(AbstractSession session, ForeignReferenceMapping mapping) { if (getTargetRelationKeyFields().size() == 0) { throw DescriptorException.noTargetRelationKeysSpecified(mapping); } for (Enumeration targetEnum = getTargetRelationKeyFields().elements(); targetEnum.hasMoreElements();) { DatabaseField field = (DatabaseField)targetEnum.nextElement(); if (field.hasTableName() && (!(field.getTableName().equals(getRelationTable().getName())))) { throw DescriptorException.relationKeyFieldNotProperlySpecified(field, mapping); } field.setTable(getRelationTable()); } }
/** * INTERNAL: * Set the table qualifier on the relation table if required */ protected void initializeRelationTable(AbstractSession session, ForeignReferenceMapping mapping) throws DescriptorException { Platform platform = session.getDatasourcePlatform(); if (!hasRelationTable()) { throw DescriptorException.noRelationTable(mapping); } if (platform.getTableQualifier().length() > 0) { if (getRelationTable().getTableQualifier().length() == 0) { getRelationTable().setTableQualifier(platform.getTableQualifier()); } } } /**
/** * INTERNAL: * Allow the mapping the do any further batch preparation. */ protected void postPrepareNestedBatchQuery(ReadQuery batchQuery, ReadAllQuery query) { // Force a distinct to filter out m-1 duplicates. if (!query.isDistinctComputed()) { ((ObjectLevelReadQuery)batchQuery).useDistinct(); } if(this.mechanism != null) { ReadAllQuery mappingBatchQuery = (ReadAllQuery)batchQuery; mappingBatchQuery.setShouldIncludeData(true); for (Enumeration relationFieldsEnum = this.mechanism.getSourceRelationKeyFields().elements(); relationFieldsEnum.hasMoreElements();) { mappingBatchQuery.getAdditionalFields().add(mappingBatchQuery.getExpressionBuilder().getTable(this.mechanism.getRelationTable()).getField((DatabaseField)relationFieldsEnum.nextElement())); } } }
/** * INTERNAL: * All the source relation key field names are converted to DatabaseField and stored. */ protected void initializeSourceRelationKeys(ForeignReferenceMapping mapping) throws DescriptorException { if (getSourceRelationKeyFields().size() == 0) { throw DescriptorException.noSourceRelationKeysSpecified(mapping); } for (Enumeration entry = getSourceRelationKeyFields().elements(); entry.hasMoreElements();) { DatabaseField field = (DatabaseField)entry.nextElement(); // Update the fields table first if the mapping is from a table per tenant entity. ClassDescriptor sourceDescriptor = mapping.getDescriptor(); if (sourceDescriptor.hasTablePerMultitenantPolicy()) { field.setTable(((TablePerMultitenantPolicy) sourceDescriptor.getMultitenantPolicy()).getTable(field.getTable())); } if (field.hasTableName() && (!(field.getTableName().equals(getRelationTable().getName())))) { throw DescriptorException.relationKeyFieldNotProperlySpecified(field, mapping); } field.setTable(getRelationTable()); } }
/** * INTERNAL: * All the target relation key field names are converted to DatabaseField and stored. */ protected void initializeTargetRelationKeys(ForeignReferenceMapping mapping) { if (getTargetRelationKeyFields().size() == 0) { throw DescriptorException.noTargetRelationKeysSpecified(mapping); } for (Enumeration targetEnum = getTargetRelationKeyFields().elements(); targetEnum.hasMoreElements();) { DatabaseField field = (DatabaseField)targetEnum.nextElement(); // Update the fields table first if the mapping is from a table per tenant entity. ClassDescriptor referenceDescriptor = mapping.getReferenceDescriptor(); if (referenceDescriptor.hasTablePerMultitenantPolicy()) { field.setTable(((TablePerMultitenantPolicy) referenceDescriptor.getMultitenantPolicy()).getTable(field.getTable())); } if (field.hasTableName() && (!(field.getTableName().equals(getRelationTable().getName())))) { throw DescriptorException.relationKeyFieldNotProperlySpecified(field, mapping); } field.setTable(getRelationTable()); } }
/** * INTERNAL: * Set the table qualifier on the relation table if required */ protected void initializeRelationTable(AbstractSession session, ForeignReferenceMapping mapping) throws DescriptorException { Platform platform = session.getDatasourcePlatform(); // We need to look up the relation table name from the reference // descriptor if we are the non owning side of a bidirectional mapping // to a table per tenant descriptor. if (mapping.isReadOnly() && mapping.getReferenceDescriptor().hasTablePerMultitenantPolicy()) { setRelationTable(((TablePerMultitenantPolicy) mapping.getReferenceDescriptor().getMultitenantPolicy()).getTable(getRelationTable())); } if (!hasRelationTable()) { throw DescriptorException.noRelationTable(mapping); } if (platform.getTableQualifier().length() > 0) { if (getRelationTable().getTableQualifier().length() == 0) { getRelationTable().setTableQualifier(platform.getTableQualifier()); } } } /**
/** * INTERNAL: * All the target relation key field names are converted to DatabaseField and stored. */ protected void initializeTargetRelationKeys(ForeignReferenceMapping mapping) { if (getTargetRelationKeyFields().size() == 0) { throw DescriptorException.noTargetRelationKeysSpecified(mapping); } for (Enumeration targetEnum = getTargetRelationKeyFields().elements(); targetEnum.hasMoreElements();) { DatabaseField field = (DatabaseField)targetEnum.nextElement(); // Update the fields table first if the mapping is from a table per tenant entity. ClassDescriptor referenceDescriptor = mapping.getReferenceDescriptor(); if (referenceDescriptor.hasTablePerMultitenantPolicy()) { field.setTable(((TablePerMultitenantPolicy) referenceDescriptor.getMultitenantPolicy()).getTable(field.getTable())); } if (field.hasTableName() && (!(field.getTableName().equals(getRelationTable().getName())))) { throw DescriptorException.relationKeyFieldNotProperlySpecified(field, mapping); } field.setTable(getRelationTable()); } }
/** * INTERNAL: * Set the table qualifier on the relation table if required */ protected void initializeRelationTable(AbstractSession session, ForeignReferenceMapping mapping) throws DescriptorException { Platform platform = session.getDatasourcePlatform(); // We need to look up the relation table name from the reference // descriptor if we are the non owning side of a bidirectional mapping // to a table per tenant descriptor. if (mapping.isReadOnly() && mapping.getReferenceDescriptor().hasTablePerMultitenantPolicy()) { setRelationTable(((TablePerMultitenantPolicy) mapping.getReferenceDescriptor().getMultitenantPolicy()).getTable(getRelationTable())); } if (!hasRelationTable()) { throw DescriptorException.noRelationTable(mapping); } if (platform.getTableQualifier().length() > 0) { if (getRelationTable().getTableQualifier().length() == 0) { getRelationTable().setTableQualifier(platform.getTableQualifier()); } } } /**
/** * INTERNAL: * All the source relation key field names are converted to DatabaseField and stored. */ protected void initializeSourceRelationKeys(ForeignReferenceMapping mapping) throws DescriptorException { if (getSourceRelationKeyFields().size() == 0) { throw DescriptorException.noSourceRelationKeysSpecified(mapping); } for (Enumeration entry = getSourceRelationKeyFields().elements(); entry.hasMoreElements();) { DatabaseField field = (DatabaseField)entry.nextElement(); // Update the fields table first if the mapping is from a table per tenant entity. ClassDescriptor sourceDescriptor = mapping.getDescriptor(); if (sourceDescriptor.hasTablePerMultitenantPolicy()) { field.setTable(((TablePerMultitenantPolicy) sourceDescriptor.getMultitenantPolicy()).getTable(field.getTable())); } if (field.hasTableName() && (!(field.getTableName().equals(getRelationTable().getName())))) { throw DescriptorException.relationKeyFieldNotProperlySpecified(field, mapping); } field.setTable(getRelationTable()); } }
/** * Build relation table definitions for all many-to-many relationships in a EclipseLink descriptor. */ protected void buildRelationTableDefinition(ForeignReferenceMapping mapping, RelationTableMechanism relationTableMechanism, DatabaseField listOrderField, ContainerPolicy cp) { //first create relation table TableDefinition table = getTableDefFromDBTable(relationTableMechanism.getRelationTable()); //add source foreign key fields into the relation table List<DatabaseField> srcFkFields = relationTableMechanism.getSourceRelationKeyFields(); List<DatabaseField> srcKeyFields = relationTableMechanism.getSourceKeyFields(); buildRelationTableFields(mapping, table, srcFkFields, srcKeyFields); //add target foreign key fields into the relation table List<DatabaseField> targFkFields = relationTableMechanism.getTargetRelationKeyFields(); List<DatabaseField> targKeyFields = relationTableMechanism.getTargetKeyFields(); buildRelationTableFields(mapping, table, targFkFields, targKeyFields); if (cp != null){ addFieldsForMappedKeyMapContainerPolicy(cp, table); } if (listOrderField != null) { FieldDefinition fieldDef = getFieldDefFromDBField(listOrderField); if (!table.getFields().contains(fieldDef)) { table.addField(fieldDef); } } }
/** * Build relation table definitions for all many-to-many relationships in a EclipseLink descriptor. */ protected void buildRelationTableDefinition(ForeignReferenceMapping mapping, RelationTableMechanism relationTableMechanism, DatabaseField listOrderField, ContainerPolicy cp) { //first create relation table TableDefinition table = getTableDefFromDBTable(relationTableMechanism.getRelationTable()); //add source foreign key fields into the relation table List<DatabaseField> srcFkFields = relationTableMechanism.getSourceRelationKeyFields(); List<DatabaseField> srcKeyFields = relationTableMechanism.getSourceKeyFields(); buildRelationTableFields(mapping, table, srcFkFields, srcKeyFields); //add target foreign key fields into the relation table List<DatabaseField> targFkFields = relationTableMechanism.getTargetRelationKeyFields(); List<DatabaseField> targKeyFields = relationTableMechanism.getTargetKeyFields(); buildRelationTableFields(mapping, table, targFkFields, targKeyFields); if (cp != null){ addFieldsForMappedKeyMapContainerPolicy(cp, table); } if (listOrderField != null) { FieldDefinition fieldDef = getFieldDefFromDBField(listOrderField); if (!table.getFields().contains(fieldDef)) { table.addField(fieldDef); } } }
/** * Build relation table definitions for all many-to-many relationships in a EclipseLink descriptor. */ private void buildRelationTableDefinition(RelationTableMechanism relationTableMechanism, DatabaseField listOrderField, ContainerPolicy cp) { //first create relation table TableDefinition tblDef = getTableDefFromDBTable(relationTableMechanism.getRelationTable()); //add source foreign key fields into the relation table Vector srcFkFields = relationTableMechanism.getSourceRelationKeyFields(); Vector srcKeyFields = relationTableMechanism.getSourceKeyFields(); buildRelationTableFields(tblDef, srcFkFields, srcKeyFields); //add target foreign key fields into the relation table Vector targFkFields = relationTableMechanism.getTargetRelationKeyFields(); Vector targKeyFields = relationTableMechanism.getTargetKeyFields(); buildRelationTableFields(tblDef, targFkFields, targKeyFields); if (cp != null){ addFieldsForMappedKeyMapContainerPolicy(cp, tblDef); } if(listOrderField != null) { tblDef.addField(getFieldDefFromDBField(listOrderField, false)); } }
mechanism.setRelationTable(ownerMechanism.getRelationTable());