CL_Basis {abstract}
+ iID: Integer
CL_Person (parent: CL_Basis)
+ sFirstName: String
+ sLastName: String
CL_University (parent: CL_Basis)
+ sName: String
There's a many-to-one relationship between CL_Person and
CL_University.
Persistent properties for CL_Basis are set as follow:
- Persistence: Persistent
- Table Mapping: Children
- iID --> persistent, DbAssign, AutoInc, ColumnName = id
My intention is to use these 2 tables to map the hierarchy :
tb_people
id: int identity(1,1) [primary key]
first_name: varchar(20)
last_name: varchar(20)
tb_universities
id: int identity(1,1) [primary key]
name: varchar(20)
And this is my mapping file:
<ClassDef Name="CL_Basis">
<KeyDef Name="EcoKey" Signature="System.Int32" IsId="True"
KeyMapper="AutoInc" />
</ClassDef>
<ClassDef Name="CL_Person" SuperClass="CL_Basis">
<AliasDef Name="tb_people_ALIAS" Table="tb_people"
ExtentRequiresDiscriminator="False">
<KeyImpl Name="EcoKey">
<KeyColumn Name="id" />
</KeyImpl>
</AliasDef>
<SingleLinkDef Name="university" Alias="tb_people_ALIAS"
Columns="university_id" Key="CL_University.EcoKey" />
<AttributeDef Name="iID" Alias="tb_people_ALIAS" Columns="id" />
<AttributeDef Name="sFirstName" Alias="tb_people_ALIAS"
Columns="firstName" />
<AttributeDef Name="sLastName" Alias="tb_people_ALIAS"
Columns="lastName" />
</ClassDef>
<ClassDef Name="CL_University" SuperClass="CL_Basis">
<AliasDef Name="tb_universities_ALIAS" Table="tb_universities"
ExtentRequiresDiscriminator="False">
<KeyImpl Name="EcoKey">
<KeyColumn Name="id" />
</KeyImpl>
</AliasDef>
<AttributeDef Name="iID" Alias="tb_universities_ALIAS" Columns="id" /
>
<AttributeDef Name="sName" Alias="tb_universities_ALIAS"
Columns="name" />
</ClassDef>
But at runtime I get an exception saying there's no definition for
attribute iID in class CL_Basis.
I tried some different layout for the xml file but the only way I
could get it to work was to remove the abstract class from the model
moving the iID attribute in the subclasses.
Does anyone have any hint about that or even an example of mapping an
hierarchy like this?
Thanks
Emiliano
Boia...che vespaio ho sollevato!