0

Folks, The problem statement can be found as follows, Background:

  1. the application collect user information, which can be modeled by AggregateA, and AggregateB;
  2. AggregateA contains a collection of AggregateB
  3. AggregateA/B contains a small number of Entities
  4. the application persists AggregateA then AggregateB (the primary key of AggregateA is used an input to persist AggregateB)

Question: in the service layer, is there any alternative to this?

def add_user_info(varA, varB):
    A_ID = repoA.add(varA)
    repoA.commit()
    repoB.add(A_ID, varB)
    repoB.commit()    

is it possible to have a single commit in this insertion?

bruinon
  • 11
  • 2
  • You should have a single commit for both repository operations, please consider using the unit-of-work pattern (general concept is having a single-instance session object encapsulated by each repository object and by unit-of-work object). – desertech Jul 31 '23 at 18:02

0 Answers0