public void map(boolean adapt) {
if (cls.getEmbeddingMetaData() != null)
throw new MetaDataException(_loc.get("not-full", cls));
ClassMapping sup = cls.getMappedPCSuperclassMapping();
ClassMappingInfo info = cls.getMappingInfo();
if (sup != null && info.isJoinedSubclass())
throw new MetaDataException(_loc.get("not-full", cls));
info.assertNoJoin(cls, true);
info.assertNoForeignKey(cls, !adapt);
info.assertNoIndex(cls, false);
info.assertNoUnique(cls, false);
// find class table
Table table = info.getTable(cls, adapt);
// find primary key column
Column[] pkCols = null;
if (cls.getIdentityType() == cls.ID_DATASTORE) {
Column id = new Column();
DBDictionary dict = cls.getMappingRepository().getDBDictionary();
DBIdentifier idName = DBIdentifier.newColumn("id", dict != null ? dict.delimitAll() : false);
id.setIdentifier(idName);
id.setJavaType(JavaTypes.LONG);
id.setComment("datastore id");
if (cls.getIdentityStrategy() == ValueStrategies.AUTOASSIGN)
id.setAutoAssigned(true);
id.setNotNull(true);
pkCols = info.getDataStoreIdColumns(cls, new Column[]{ id },
table, adapt);
cls.setPrimaryKeyColumns(pkCols);
cls.setColumnIO(info.getColumnIO());
}
cls.setTable(table);
// add a primary key if we don't have one already
PrimaryKey pk = table.getPrimaryKey();