I would like to intercept persistence operations over collection properties, decide by myself if it can be synchronized with database, and call a procedure when a persistence is decided to occur over all collection at once and not by each element.
How to do that ?
These collection properties are usually mapped with one-to-many or many-to-many associations. So, when we have something like this:
myEntity.List.Add(new Item());
myEntity.List.Add(new Item());
...
session.Save(myEntity);
For a mapping having two classes (entities) and an unidirectional many-to-many association, I would like to have only two sql statements occurring: INSERT INTO
, and a PROCEDURE CALL
which expects to receive a list of values comma-separated that is the key values from the List
collection above. The collection of keys can only be saved on this system calling a procedure with a list of values (csv).
This kind of customizing is possible to be done ?