* within a ClassMapping element and <em>not</em> within a secondary
* table. The stack is popped and the Unique element is added to the
* ClassMappingInfo.
*/
private void endUniqueConstraint() {
Unique unique = (Unique) popElement();
Object ctx = currentElement();
DBIdentifier tableName = DBIdentifier.newTable("?");
if (ctx instanceof ClassMapping) {
ClassMappingInfo info = ((ClassMapping) ctx).getMappingInfo();
tableName = (_secondaryTable == null)
? info.getTableIdentifier() : DBIdentifier.newTable(_secondaryTable, delimit());
info.addUnique(tableName, unique);
} else if (ctx instanceof FieldMapping) {// JoinTable
FieldMappingInfo info = ((FieldMapping)ctx).getMappingInfo();
info.addJoinTableUnique(unique);
} else if (ctx instanceof SequenceMapping) {
SequenceMapping seq = (SequenceMapping)ctx;
unique.setTableIdentifier(seq.getTableIdentifier());
Column[] uniqueColumns = unique.getColumns();
DBIdentifier[] columnNames = new DBIdentifier[uniqueColumns.length];
int i = 0;
for (Column uniqueColumn : uniqueColumns)
columnNames[i++] = uniqueColumn.getIdentifier().clone();
seq.setUniqueColumnsIdentifier(columnNames);
if (!DBIdentifier.isEmpty(unique.getIdentifier())) {
seq.setUniqueConstraintIdentifier(unique.getIdentifier());
}
} else {
throw new InternalException();
}
}