protected override void AddMappings(Configuration configuration) { var xml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?><hibernate-mapping xmlns=\"urn:nhibernate-mapping-2.2\" namespace=\"NHibernate.Test.VersionTest.Db\" assembly=\"NHibernate.Test\"><class name=\"ProductWithVersionAndLazyProperty\"><id name=\"Id\" generator=\"assigned\"/><version name=\"Version\" generated=\"always\" unsaved-value=\"null\" type=\"BinaryBlob\" access=\"nosetter.camelcase-underscore\"><column name=\"version\" not-null=\"false\" sql-type=\"timestamp\" /></version><property name=\"Summary\" lazy=\"true\"/></class></hibernate-mapping>"; var doc = new XmlDocument(); doc.LoadXml(xml); configuration.AddDocument(doc); base.AddMappings(configuration); configuration.SetProperty(NHibernate.Cfg.Environment.Hbm2ddlAuto, SchemaAutoAction.Recreate.ToString()); configuration.SetProperty(NHibernate.Cfg.Environment.FormatSql, Boolean.TrueString); configuration.SetProperty(NHibernate.Cfg.Environment.ShowSql, Boolean.TrueString); }
public void AddDocument() { string hbm = @"<?xml version='1.0' ?> <hibernate-mapping xmlns='urn:nhibernate-mapping-2.0'> <class name='NHibernate.DomainModel.A, NHibernate.DomainModel'> <id name='Id' column='somecolumn'> <generator class='native' /> </id> </class> </hibernate-mapping>"; Configuration cfg = new Configuration(); XmlDocument doc = new XmlDocument(); doc.LoadXml( hbm ); cfg.AddDocument( doc ); }
public virtual void Configure(Configuration cfg) { EnsureMappingsBuilt(); foreach (var mapping in compiledMappings) { var serializer = new MappingXmlSerializer(); XmlDocument document = serializer.Serialize(mapping); if (cfg.GetClassMapping(mapping.Classes.First().Type) == null) cfg.AddDocument(document); } }
public void Configure(Configuration cfg) { var rootMapping = BuildHibernateMapping(); ApplyVisitors(rootMapping); var serializer = new MappingXmlSerializer(); XmlDocument document = serializer.Serialize(rootMapping); cfg.AddDocument(document); }