Project

General

Profile

multiple tables mapped from one class -- how to add a record?

Added by Thomas Lynch over 10 years ago

all surveys have the same schema, they are just tables of questions:

session_.mapClass("survey1");

session_.mapClass("survey2");

add() has the syntax of:

session_.add(new question); // hey, how does it know which table to put the new record in?

.. how do you do multiple tables?


Replies (3)

RE: multiple tables mapped from one class -- how to add a record? - Added by Saif Rehman over 10 years ago

I think Dbo would require you have a different class for each table. What I think you should do is create an abstract class "AbstractQuestion" and derive the 2 dbo classes from that base class "Question1", "Question2"

RE: multiple tables mapped from one class -- how to add a record? - Added by Thomas Lynch over 10 years ago

Very intersting, so a class which describes a 'type' or 'schema' in C becomes a state holding object for a table, and the abstract parent is then the description of type. So then the virtual table in the parent points to methods in the child classes, so there is no overhead for the child classes. It is a little funny to have identical child classes ..

RE: multiple tables mapped from one class -- how to add a record? - Added by Wim Dumon over 10 years ago

You could consider to design your database differently, by creating a 'Survey' class to which a 'Question' class belongs. I believe this scales better than to have a database with large amounts of tables.

Wim.

    (1-3/3)