I'm a little unclear on why the code is in ClassMapping, too. It seems like it could go in the SchemaGenerator along with generatePrimaryKeys(), generateIndexes(), etc.
Pinaki, is there any reason why we can't move the code into a more common location? On 1/3/07, Abe White <[EMAIL PROTECTED]> wrote:
I don't agree with this implementation. It doesn't leave any room for customization through MappingDefaults, it ties the ClassMapping to the XMLSchemaParser (?!), and it's totally different than our mapping of indexes, foreign keys, and primary keys, the other supported constraint types. > + mapUniqueConstraints(); > + } > + > + /** > + * Adds unique constraints to the mapped table. > + * > + */ > + void mapUniqueConstraints() { > + Log log = getRepository().getLog(); > + Collection uniqueInfos = _info.getUniqueConstraints(); > + if (uniqueInfos == null || uniqueInfos.isEmpty()) > + return; > + Iterator iter = uniqueInfos.iterator(); > + Table table = getTable(); > + int i = 1; > + while (iter.hasNext()) { > + XMLSchemaParser.UniqueInfo uniqueInfo = > + (XMLSchemaParser.UniqueInfo)iter.next(); > + if (uniqueInfo.cols == null || uniqueInfo.cols.isEmpty()) > + continue; > + String constraintName = table.getName() + "_UNIQUE_" + i; > + i++; > + Unique uniqueConstraint = table.addUnique > (constraintName); > + Iterator uniqueColumnNames = uniqueInfo.cols.iterator(); > + while (uniqueColumnNames.hasNext()) { > + String uniqueColumnName = (String) > uniqueColumnNames.next(); > + Column uniqueColumn = table.getColumn > (uniqueColumnName); > + if (uniqueColumn != null) { > + uniqueConstraint.addColumn(uniqueColumn); > + } else { > + table.removeUnique(uniqueConstraint); > + if (log.isWarnEnabled()) > + log.warn(_loc.get("missing-unique-column", > this, > + table.getName(), uniqueColumnName)); > + break; > + } > } > } > } _______________________________________________________________________ Notice: This email message, together with any attachments, may contain information of BEA Systems, Inc., its subsidiaries and affiliated entities, that may be confidential, proprietary, copyrighted and/or legally privileged, and is intended solely for the use of the individual or entity named in this message. If you are not the intended recipient, and have received this message in error, please immediately return this by email and then delete it.
-- -Michael Dick