using NHibernate.Cfg; using NHibernate.Mapping; namespace Sample { public class Remapper { public static Configuration Remap (Configuration config) { var remapper = new Remapper (config); return remapper.Remap (); } readonly Configuration config; readonly bool isOracle; Remapper (Configuration configuration) { config = configuration; isOracle = config.Properties["dialect"].ToLower ().Contains ("oracle"); } Configuration Remap () { foreach (var classMap in config.ClassMappings) { RemapTableName (classMap); RemapSequence (classMap); } foreach (var collectionMap in config.CollectionMappings) { RemapLinkTableName (collectionMap); } return config; } void RemapTableName (PersistentClass classMap) { FixOracleName (classMap.Table); } void RemapLinkTableName (Collection collectionMap) { //remapping root table takes care of collectionMap.Table FixOracleName (collectionMap.CollectionTable); } void RemapSequence (PersistentClass classMap) { if (isOracle) return; if (classMap.Identifier.IsSimpleValue) { var simpleVal = classMap.Identifier as SimpleValue; simpleVal.IdentifierGeneratorProperties.Remove ("sequence"); } } void FixOracleName (Table table) { if (isOracle) { table.Name = table.Name.Substring (0, 30); } } } }