标签云

微信群

扫码加入我们

WeChat QR Code

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 ?


Way to go, Luciano!

2019年04月22日12分44秒

Thanks by answer . I'm trying another approach based on what NHibernate.Envers does. This Framework intercepts some operations using listeners and inject new database operations to save auditing information before the commit. I analyzed yesterday its source code and already tried some injections, as soon as I finish my solution I publish it here. Track it.

2019年04月22日12分44秒

OK, interesting. Maybe you can post an answer to your own question when you know more.

2019年04月22日12分44秒