I have entity types A and B that have a many to many relationship in my db .
I wish to trigger an event upon the change in the members of any groups of entity B with a common set or relationships to entity type As.
we have A(1) A(2) A(3), and B(1) B(2) B(3)
if we insert the following relationships
we have 2 groups,
G(1)= B(1) and B(2) both have the commons set of relations to A(1) AND A(2) ,
G(2) = B(3) the second group containing only relations to A(1) and nothing else
if we add
we now have three groups all containing just one B,
and G(2), created on the initial insert, is now empty but still requires an event
I want an event for each of those four groups
Currently I do this by hashing the set of As belonging to any B and then group the Bs on that value
I perform these inserts in massive blocks (100,000 As each with ab average of over 100 Bs) so its efficient enough, but the code is hell of course. I have to instantiate the groups as entities in my DB as they form, and ensure that all groups affected get an event.
Can you help ?