Ok i have found the problem. The data in the DB was corrupted. The
vertical table in one of the inheritaed classes didnt have the right
records so NH try to create the abstract class.

Noam

On Aug 12, 9:40 pm, Noam <[email protected]> wrote:
> Here are the mappings. i am using mix of Auto mapping and override
> mapping. i have included the mapping classes and the model classes.
> once i put the AttributeTemplate to be abstract i cannot query it.
>
> This is the query i am using. BTW if i remove the abstract from the
> AttributeTemplate then its all working fine.
>
> public IList<AttributeTemplate> AttributeTemplates
>         {
>             get
>             {
>                 var cr = _session.CreateCriteria(typeof
> (AttributeTemplate));
>                 return cr.List<AttributeTemplate>();
>             }
>         }
>
> ------------------------------------------------Those are the mappings
> ------------------
> public class EntityMap : IAutoMappingOverride<Entity>
>     {
>         public void Override(AutoMapping<Entity> mapping)
>         {
>             mapping.Table("tbl_Entity");
>             mapping.Id(x => x.Id)
>                 .UnsavedValue(0)
>                 .GeneratedBy.Identity();
>
>             mapping.Map(x => x.CreatedDate);
>             mapping.Map(x => x.UpdatedDate);
>         }
>     }
>
> public class EntityTemplateMap : IAutoMappingOverride<EntityTemplate>
>     {
>         public void Override(AutoMapping<EntityTemplate> mapping)
>         {
>             mapping.Table("tbl_EntityTemplate");
>         }
>     }
>
> public class AttributeTemplateMap :
> IAutoMappingOverride<AttributeTemplate>
>     {
>         public void Override(AutoMapping<AttributeTemplate> mapping)
>         {
>             mapping.Table("tbl_AttributeTemplate");
>         }
>     }
>
> public class ATImageMap : IAutoMappingOverride<ATImage>
>     {
>         public void Override(AutoMapping<ATImage> mapping)
>         {
>             mapping.Table("tbl_ATImage");
>         }
>     }
>
> -------------------------------- And here are the model
> classes-----------------------------
>
> public abstract class Entity
>     {
>         protected Entity()
>         {
>             CreatedDate = UpdatedDate = DateTime.Now;
>         }
>
>         [Key]
>         public virtual int Id { get; set; }
>
>         public virtual DateTime CreatedDate { get; set; }
>         public virtual DateTime UpdatedDate { get; set; }
>     }
>
> public abstract class EntityTemplate :Entity
>     {
>
>     }
>
> public abstract class AttributeTemplate : EntityTemplate
>     {
>         public virtual string Title { get; set; }
>         public virtual string CodeName { get; set; }
>         public virtual bool Descriptor { get; set; }
>     }
>
> public class ATImage : AttributeTemplate
>     {
>
>     }
>
> public class ATLocation : AttributeTemplate
>     {
>
>     }
>
> On Aug 12, 8:46 pm, Fabio Maulo <[email protected]> wrote:
>
>
>
> > Hi Noan.
> > If you are using Fluent-NHibernat, can you show us your FNH mapping ?
> > Thanks.
>
> > On Thu, Aug 12, 2010 at 6:05 AM, Noam <[email protected]> wrote:
> > > Hi Guys,
> > > I am getting this exception when i have an abstract class that i am
> > > trieng to query. what can be the problem?
>
> > > This is my mapping XML
>
> > > - <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-
> > > access="property" auto-import="true" default-cascade="none" default-
> > > lazy="true">
> > > - <class xmlns="urn:nhibernate-mapping-2.2" mutable="true"
> > > name="Promo.NH.Model.Entity, Promo.NH, Version=1.0.0.0,
> > > Culture=neutral, PublicKeyToken=null" table="tbl_Entity">
> > > - <id name="Id" type="System.Int32, mscorlib, Version=4.0.0.0,
> > > Culture=neutral, PublicKeyToken=b77a5c561934e089" unsaved-value="0">
> > >  <column name="Id" />
> > >  <generator class="identity" />
> > >  </id>
> > > - <property name="CreatedDate" type="System.DateTime, mscorlib,
> > > Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
> > >  <column name="CreatedDate" />
> > >  </property>
> > > - <property name="UpdatedDate" type="System.DateTime, mscorlib,
> > > Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
> > >  <column name="UpdatedDate" />
> > >  </property>
> > > - <joined-subclass name="Promo.NH.Model.EntityTemplate, Promo.NH,
> > > Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
> > > table="tbl_EntityTemplate">
> > > - <key>
> > >  <column name="Entity_id" />
> > >  </key>
> > > - <joined-subclass name="Promo.NH.Model.AttributeTemplate, Promo.NH,
> > > Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
> > > table="tbl_AttributeTemplate">
> > > - <key>
> > >  <column name="EntityTemplate_id" />
> > >  </key>
> > > - <property name="Title" type="System.String, mscorlib,
> > > Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
> > >  <column name="Title" />
> > >  </property>
> > > - <property name="CodeName" type="System.String, mscorlib,
> > > Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
> > >  <column name="CodeName" />
> > >  </property>
> > > - <property name="Descriptor" type="System.Boolean, mscorlib,
> > > Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
> > >  <column name="Descriptor" />
> > >  </property>
> > > - <joined-subclass name="Promo.NH.Model.AttributeTemplates.ATHtml,
> > > Promo.NH, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
> > > table="tbl_ATHtml">
> > > - <key>
> > >  <column name="AttributeTemplate_id" />
> > >  </key>
> > >  </joined-subclass>
> > > - <joined-subclass name="Promo.NH.Model.AttributeTemplates.ATImage,
> > > Promo.NH, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
> > > table="tbl_ATImage">
> > > - <key>
> > >  <column name="AttributeTemplate_id" />
> > >  </key>
> > >  </joined-subclass>
> > > - <joined-subclass
> > > name="Promo.Core.MetaModel.AttributeTemplates.ATLocation, Promo.NH,
> > > Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
> > > table="tbl_ATLocation">
> > > - <key>
> > >  <column name="AttributeTemplate_id" />
> > >  </key>
> > >  </joined-subclass>
> > > - <joined-subclass name="Promo.NH.Model.AttributeTemplates.ATPassword,
> > > Promo.NH, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
> > > table="tbl_ATPassword">
> > > - <key>
> > >  <column name="AttributeTemplate_id" />
> > >  </key>
> > >  </joined-subclass>
> > > - <joined-subclass
> > > name="Promo.NH.Model.AttributeTemplates.ATPhoneNumber, Promo.NH,
> > > Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
> > > table="tbl_ATPhoneNumber">
> > > - <key>
> > >  <column name="AttributeTemplate_id" />
> > >  </key>
> > >  </joined-subclass>
> > > - <joined-subclass
> > > name="Promo.NH.Model.AttributeTemplates.ATSingleLineText, Promo.NH,
> > > Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
> > > table="tbl_ATSingleLineText">
> > > - <key>
> > >  <column name="AttributeTemplate_id" />
> > >  </key>
> > >  </joined-subclass>
> > >  </joined-subclass>
> > >  </joined-subclass>
> > >  </class>
> > >  </hibernate-mapping>
>
> > > --
> > > You received this message because you are subscribed to the Google Groups
> > > "nhusers" group.
> > > To post to this group, send email to [email protected].
> > > To unsubscribe from this group, send email to
> > > [email protected]<nhusers%[email protected]­­>
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/nhusers?hl=en.
>
> > --
> > Fabio Maulo- Hide quoted text -
>
> > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to