Listen to edits in a container

I have a container in which I want to listen for all type of edits, in case I need to update the database. Let’s say an item has been added, then I want to add that one in the database as well. If an item has been edited, I want to update the database with the edit.

I didn’t understand any obvious way to handle this and I guess I have missed something, right?

If not, am I supposed to create a custom container just to handle all those things manually? (At the addItem functions and stuff)

Thank you :slight_smile:

Events fired by Container do not indicate which item has been added/removed, so proper implementation of Container (and underlying Items/Properties, actually) is required.

Container implementations available in the Directory may suit your needs, check them out eventually.

In my opinion such proper implementation should track changes made to objects and allow committing cumulative changes. In order to achieve this, at least methods listed below should be database-aware:

  • Container.add*, Container.remove* methods, in all possible flavors (some can not be easily implemented with relational database in mind)
  • Property.setValue method, for registration of changes resulting in database update

It would be quite tedious task, but well worth the effort if you plan to use such Container frequently.at le

Hi Erik.
The HibernateContainer may hit your needs. If not i think your custom container should handle add and remove
actions while the contained items can handle the update operations.

cheers
stefan