/** * Build direct collection table definitions in a EclipseLink descriptor */ private void buildDirectCollectionTableDefinition(DirectCollectionMapping mapping, ClassDescriptor desc) { //first create direct collection table TableDefinition tblDef = getTableDefFromDBTable(mapping.getReferenceTable()); DatabaseField dbField = null; //add the table reference key(s) Vector refPkFields = mapping.getReferenceKeyFields(); for (int index = 0; index < refPkFields.size(); index++) { dbField = resolveDatabaseField((DatabaseField) refPkFields.get(index), mapping.getSourceKeyFields().get(index)); tblDef.addField(getDirectCollectionReferenceKeyFieldDefFromDBField(dbField)); } //add the direct collection field to the table. tblDef.addField(getFieldDefFromDBField(mapping.getDirectField(), false)); //if the mapping is direct-map field, add the direct key field to the table as well. // TODO: avoid generating DDL for map key mappings for the time being. // Bug: 270814 if (mapping.isDirectMapMapping() && ! mapping.getContainerPolicy().isMappedKeyMapPolicy() ) { dbField = ((DirectMapMapping) mapping).getDirectKeyField(); tblDef.addField(getFieldDefFromDBField(dbField, false)); } else { addFieldsForMappedKeyMapContainerPolicy(mapping.getContainerPolicy(), tblDef); if(mapping.getListOrderField() != null) { tblDef.addField(getFieldDefFromDBField(mapping.getListOrderField(), false)); } } }