Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Mapping hierarchy to a legacy DB

2 views
Skip to first unread message

giovannett...@gmail.com

unread,
Oct 21, 2008, 5:02:29 AM10/21/08
to
Hi all,
I would like to persist a model to a legacy database but I can't
figure how to correctly xml-mapping it.
Say I have this (simplified) hierarchy:

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

blablas

unread,
Oct 21, 2008, 5:45:55 AM10/21/08
to
I'm using BDS 2006 Enterprise Edition Update2 (up to hotfix 13) and
ECOIII

Emiliano

blablas

unread,
Oct 31, 2008, 4:11:50 AM10/31/08
to

Boia...che vespaio ho sollevato!

0 new messages