Hola, estoy migrando de conform 1.0.0.0 y nh 2.1.0.1001 a conform 2.0.0.0 y 
nh 3.2.0.4000 y me di cuenta de que los mappings generados son diferentes. 
Estas son las clases:
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; }    }
y estoy usando este codigo 
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);
con conform 1.0
me genera el siguiente 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>
y con 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" />
    </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>

el problema es que me cambio los many to one por los Any.... y no me respeta 
los cascade ni los lazy...
entiendo que en conform se hicieron varios cambios sobre la herencia con 
interfaces, pero no se como decirle a conform que me las mapee con una many to 
one.
gracias


Mario Dal Lago

-- 
Para escribir al Grupo, hágalo a esta dirección: 
[email protected]
Para más, visite: http://groups.google.com/group/NHibernate-Hispano

Responder a