These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Inheritence Mapping
PostPosted: Fri May 08, 2009 5:52 am 
Newbie

Joined: Fri May 08, 2009 5:38 am
Posts: 1
Hi,

I'm looking for mapping an inherit class.
I got 2 class : Report and SpyReport.

Here is my code :
Code:
    public abstract class Report
    {
        public virtual int Id_rpt { get; set; }
        public virtual int Id_profil { get; set; }
        public virtual int Uid_a { get; set; }
        public virtual int Uid_d { get; set; }
        public virtual int Vid_a { get; set; }
        public virtual int Vid_d { get; set; }
        public virtual int Res1 { get; set; }
        public virtual int Res2 { get; set; }
        public virtual int Res3 { get; set; }
        public virtual int Res4 { get; set; }
        public virtual int Date_rpt { get; set; }
    }

Code:
    public class SpyReport : Report
    {
        public virtual int UTotal_a { get; set; }
        public virtual int UTotal_d { get; set; }
        public virtual int PertesTotal_a { get; set; }
    }


I want a table-per-concrete-class, so i try to apply the explained strategy in Chap.8.
I got a SpyReport.hbm.xml file :
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
                   assembly="TravianTool3"
                   namespace="TravianTool3.Entities">

  <class name="SpyReport">
    <id name="Id_rpt" column="Id" type="Int32">
      <generator class="increment" />
    </id>
    <property name="Id_profil" column="Id_profil"/>
    <property name="Uid_a" column="Uid_A" />
    <property name="Uid_d" column="Uid_D" />
    <property name="Vid_a" column="Vid_A" />
    <property name="Vid_d" column="Vid_A" />
    <property name="Res1" column="Res1" />
    <property name="Res2" column="Res2" />
    <property name="Res3" column="Res3" />
    <property name="Res4" column="Res4" />
    <property name="Date_rpt" column="Date_rpt" />
    <property name="UTotal_a" column="UTotal_A" />
    <property name="UTotal_d" column="UTotal_D" />
    <property name="PertesTotal_a" column="PertesTotal_A" />

    <any name="Report" meta-type="class" id-type="Int32">
      <column name="Id_rpt" />
      <column name="Id_profil" />
      <column name="Uid_a" />
      <column name="Uid_d" />
      <column name="Vid_a" />
      <column name="Vid_d" />
      <column name="Res1" />
      <column name="Res2" />
      <column name="Res3" />
      <column name="Res4" />
      <column name="Date_rpt" />     
    </any>
  </class>
</hibernate-mapping>


With this code, i got an error when testing it :
Quote:
TestFixture failed: NHibernate.MappingException : property mapping has wrong number of columns:
Entities.SpyReport.Report type: Object


If i doesn't put the <any> section, i can create the table, but when i try to insert, it fail.
Quote:
failed: System.ArgumentOutOfRangeException : L'index était hors limites. Il ne doit pas être négatif et doit être inférieur à la taille de la collection.
Nom du paramètre : index


What am i missing ?
Thank to everyone who try to help me :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.