hello, i'm migrating from conform 1.0.0.0 with nh 2.1.0.1001 to conform 2.0.0.0 with nh 3.2.0.4000 and the generated
mapping are different. public interface IRule : IEntity { bool Evaluate(object instance); } public abstract class AbstractRule
: Entity, IRule { public virtual string PropertyName { get; protected set; } public virtual string ExpectedValue {
get; protected set; } public virtual Type Type { get; protected set; } } public class AndRule : Entity, IRule { protected AndRule() { } public virtual IRule LeftRule { get; protected set; } public virtual IRule RigthRule { get; protected set; } } public class EqualsRule : AbstractRule { protected EqualsRule() { } } public class RulesSet : Entity { public virtual string Description { get; set; } public virtual IRule ParentRule { get; set; } public virtual Type RootType { get; set; } } i'm, using this code to configure nh IEnumerable<Type> mappings = new List<Type>
{ typeof (RulesSet), typeof (AbstractRule), typeof (IRule), typeof (AndRule), typeof (EqualsRule)
}; var orm = new ObjectRelationalMapper(); orm.TablePerClass(new[] { typeof(RulesSet) }); orm.TablePerClassHierarchy(new[] { typeof(IRule)
}); orm.Cascade<RulesSet, IRule>(CascadeOn.All); var mapper = new Mapper(orm); mapper.Class<IRule>(pc => pc.Table("Rules"));
mapper.Class<AndRule>(pc => { pc.ManyToOne(x => x.LeftRule, mom => { mom.Cascade(Cascade.Persist); mom.Lazy(LazyRelation.NoLazy); }); pc.ManyToOne(x
=> x.RigthRule, mom => { mom.Lazy(LazyRelation.NoLazy); mom.Cascade(Cascade.Persist); }); }); mapper.Class<RulesSet>(pc => pc.ManyToOne(r => r.ParentRule, mom => mom.Lazy(LazyRelation.NoLazy))); return
mapper.CompileMappingFor(mappings); with Conform 1.0 this is the generated mapping : <?xml version="1.0" encoding="utf-8"?> <hibernate-mapping xmlns:xsi=" http://www.w3.org/2001/ XMLSchema-instance" xmlns:xsd= "http://www.w3.org/2001/ XMLSchema" assembly=" RulesEngine.Core" xmlns="urn: nhibernate-mapping-2.2"> <class name="RulesEngine.Core.Rules.RulesSet"> <id name="Id" type="Int32"> <generator class="hilo" /> </id> <property name="Description" /> <many-to-one name="ParentRule" cascade="all" lazy="false" /> <property name="RootType" /> </class> <class name="RulesEngine.Core.Rules.IRule" table="Rules" abstract="true"> <id name="Id" type="Int32"> <generator class="hilo" /> </id> <discriminator /> </class> <subclass name="RulesEngine.Core.Rules.AbstractRule" extends="RulesEngine.Core.Rules.IRule"> <property name="PropertyName" /> <property name="ExpectedValue" /> <property name="Type" /> </subclass> <subclass name="RulesEngine.Core.Rules.AndRule" extends="RulesEngine.Core.Rules.IRule"> <many-to-one name="LeftRule" cascade="save-update, persist" lazy="false" /> <many-to-one name="RigthRule" cascade="save-update, persist" lazy="false" /> </subclass> <subclass name="RulesEngine.Core.Rules.Impl.EqualsRule" extends="RulesEngine.Core.Rules.AbstractRule" /> </hibernate-mapping> and with conform 2.0 : <?xml version="1.0" encoding="utf-8"?> <hibernate-mapping xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" assembly="RulesEngine.Core" xmlns="urn:nhibernate-mapping-2.2"> <class name="RulesEngine.Core.Rules.RulesSet"> <id name="Id" type="Int32"> <generator class="hilo" /> </id> <property name="Description" /> <any id-type="Int32" name="ParentRule"> <column name="ParentRuleClass" /> <column name="ParentRuleId" /> & nbsp; </any> <property name="RootType" /> </class> <class name="RulesEngine.Core.Rules.IRule" table="Rules" abstract="true"> <id name="Id" type="Int32"> <generator class="hilo" /> </id> <discriminator /> </class> <subclass name="RulesEngine.Core.Rules.AbstractRule" extends="RulesEngine.Core.Rules.IRule"> <property name="PropertyName" /> <property name="ExpectedValue" /> <property name="Type" /> </subclass> <subclass name="RulesEngine.Core.Rules.AndRule" ;extends="RulesEngine.Core.Rules.IRule"> <any id-type="Int32" name="LeftRule"> <column name="LeftRuleClass" /> <column name="LeftRuleId" /> </any> <any id-type="Int32" name="RigthRule"> <column name="RigthRuleClass" /> <column name="RigthRuleId" /> </any> </subclass> <subclass name="RulesEngine.Core.Rules.Impl.EqualsRule" extends="RulesEngine.Core.Rules.AbstractRule" /> </hibernate-mapping> the problem is the many to one changed to Any mapping in addition didn't mantein the cascade and lazy thanks in advance Mario Dal Lago |
oh, ok... you are rigth... i'll try to remove the polymorphic pack and test again. |