ClassMapping cls = vers.getClassMapping();
if (cls.getJoinablePCSuperclassMapping() != null
|| cls.getEmbeddingMetaData() != null)
throw new MetaDataException(_loc.get("not-base-vers", cls));
VersionMappingInfo info = vers.getMappingInfo();
info.assertNoJoin(vers, true);
info.assertNoForeignKey(vers, !adapt);
info.assertNoUnique(vers, false);
if (info.getColumns().size() > 1) {
Column[] templates = new Column[info.getColumns().size()];
for (int i = 0; i < info.getColumns().size(); i++) {
templates[i] = new Column();
Column infoColumn = (Column)info.getColumns().get(i);
templates[i].setTableIdentifier(infoColumn.getTableIdentifier());
templates[i].setType(infoColumn.getType());
templates[i].setSize(infoColumn.getSize());
templates[i].setDecimalDigits(infoColumn.getDecimalDigits());
templates[i].setJavaType(getJavaType(i));
templates[i].setIdentifier(infoColumn.getIdentifier());
}
Column[] cols = info.getColumns(vers, templates, adapt);
for (int i = 0; i < cols.length; i++)
cols[i].setVersionStrategy(this);
vers.setColumns(cols);
vers.setColumnIO(info.getColumnIO());
} else {
Column tmplate = new Column();
tmplate.setJavaType(getJavaType());
DBDictionary dict = vers.getMappingRepository().getDBDictionary();
DBIdentifier versName = DBIdentifier.newColumn("versn", dict != null ? dict.delimitAll() : false);
tmplate.setIdentifier(versName);
Column[] cols = info.getColumns(vers, new Column[]{ tmplate },
adapt);
cols[0].setVersionStrategy(this);
vers.setColumns(cols);
vers.setColumnIO(info.getColumnIO());
Index idx = info.getIndex(vers, cols, adapt);
vers.setIndex(idx);
}
}