Implementing 1 to n mapping for ORM c++
- by karan
I am writing a project where I need to implement a stripped down version of an ORM solution in C++. I am struck in implementing 1-n relationships for the same.
For instance, if the following are the classes:
class A
{
...
}
class B
{
...
std::list<A> _a_list;
...
}
I have provided load/save methods for loading/saving to the db.
Now, if I take the case of B and the following workflow:
1 entry from _a_list is removed
1 entry from _a_list is modified
1 entry is added to _a_list
Now, I need to update the db using something like "b.save()".
So, what would be the best way to save the changes, i.e, identify the additions, deletions and updates to _a_list.