Log log = getLog();
if (log.isTraceEnabled())
log.trace(_loc.get("parse-gen", name));
SequenceMapping meta = (SequenceMapping) getRepository().
getCachedSequenceMetaData(name);
if (meta != null) {
if (log.isWarnEnabled())
log.warn(_loc.get("dup-gen", name, el));
return;
}
meta = (SequenceMapping) getRepository().addSequenceMetaData(name);
meta.setSequencePlugin(SequenceMapping.IMPL_VALUE_TABLE);
String schema = _dict.delimitString(gen.schema(),
DBDictionary.DBIdentifiers.TABLE_GEN_SCHEMA);
String table = _dict.delimitString(gen.table(),
DBDictionary.DBIdentifiers.TABLE_GEN_TABLE);
meta.setTable(toTableName(schema,table));
String pkColumnName = _dict.delimitString(gen.pkColumnName(),
DBDictionary.DBIdentifiers.TABLE_GEN_PK_COLUMN);
meta.setPrimaryKeyColumn(pkColumnName);
String valueColumnName = _dict.delimitString(gen.valueColumnName(),
DBDictionary.DBIdentifiers.TABLE_GEN_VALUE_COLUMN);
meta.setSequenceColumn(valueColumnName);
meta.setPrimaryKeyValue(gen.pkColumnValue());
meta.setInitialValue(gen.initialValue());
meta.setAllocate(gen.allocationSize());
meta.setSource(getSourceFile(), (el instanceof Class) ? el : null,
meta.SRC_ANNOTATIONS);
switch (gen.uniqueConstraints().length) {
case 0:
break; // nothing to do
case 1:
meta.setUniqueColumns(gen.uniqueConstraints()[0].columnNames());
meta.setUniqueConstraintName(gen.uniqueConstraints()[0].name());
break;
default:
log.warn(_loc.get("unique-many-on-seq-unsupported", el, name));
}
}