Menu

Support for One object multiple tables?

2004-09-30
2013-03-07
  • Nobody/Anonymous

    Does the framework support mapping a single object to multiple sql server tables?

    if so, sample code?

     
    • Richard Banks

      Richard Banks - 2004-10-01

      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.

       
    • Nobody/Anonymous

      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

       
    • M Benny

      M Benny - 2004-11-24

      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 ? ;)

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.