There is support for one object from multiple tables -IF- the object inherits from another persistent object. ie the parent "part" lives in table A and the subclass part is in table "B". Just set the superclass property in the XML mapping for the inherited class and set the reference columns for doing the linkage between tables.
If you are after a single object (not inherited) across 2 or more tables; no, there is no support for such an arrangement.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
There is support for one object from multiple tables -IF- the object inherits from another persistent object. ie the parent "part" lives in table A and the subclass part is in table "B". Just set the superclass property in the XML mapping for the inherited class and set the reference columns for doing the linkage between tables.
I've set the superclass property and referenced all columns.
In the database i have a table 'Person' and a table 'Student'. The PK of Student is OID, this is a FK to Person. When i want to add a new student, i get an exception concerning the PK-FK. (Seems logical, first the person needs to be inserted before data is placed in the Student table). I'v been trying to find some help on this issue but haven't found it. So how i do it ? ;)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Does the framework support mapping a single object to multiple sql server tables?
if so, sample code?
I'm not quite sure what you mean.
There is support for one object from multiple tables -IF- the object inherits from another persistent object. ie the parent "part" lives in table A and the subclass part is in table "B". Just set the superclass property in the XML mapping for the inherited class and set the reference columns for doing the linkage between tables.
If you are after a single object (not inherited) across 2 or more tables; no, there is no support for such an arrangement.
thanks, that answers my question.
I will try implementing as you suggest and see if that satisfies my requirements.
A simple example of what I am trying to do is:
Table: Person
Columns:
ID (primary key)
Name
Table: PersonDetails
Columns:
ID (primary key)
PersonID (foreign key to person table)
Address
Object: CPerson
Properties: ID, Name, Address
Hi,
I'm using the method described above:
There is support for one object from multiple tables -IF- the object inherits from another persistent object. ie the parent "part" lives in table A and the subclass part is in table "B". Just set the superclass property in the XML mapping for the inherited class and set the reference columns for doing the linkage between tables.
I've set the superclass property and referenced all columns.
In the database i have a table 'Person' and a table 'Student'. The PK of Student is OID, this is a FK to Person. When i want to add a new student, i get an exception concerning the PK-FK. (Seems logical, first the person needs to be inserted before data is placed in the Student table). I'v been trying to find some help on this issue but haven't found it. So how i do it ? ;)