title: Domain Events with Spring Boot and MongoDB
body: <p>I am working with <code>DDD</code> and <code>Spring</code> using <code>MongoDB</code>. </p>
  
  <p>Now the since <code>MongoDB</code> is a <code>DocumentDB</code> and no schema validations are present, The <code>AggregateRoot</code> and the Document class that gets stored in the MongoDB are two different classes and the <code>Repository</code> translates content between those two classes while reading and writing data to <code>database</code>. </p>
  
  <p>Since the Root entity class is different from the class being stored to DB, Spring doesn't trigger the <code>DomainEvents</code> of the <code>AggregateRoot</code>. </p>
  
  <ul>
  <li><p>Is there a way I can get trigger the events of the Root entity from the Repository after storing the data to the database? (maybe by an explicit invoke)</p></li>
  <li><p>Since the MongoDB and Aggregates are a 1:1 fit. So does that mean that we generally shouldn't make a two different classes one as <code>AggregateRoot</code> and another the Document Class for storing aggregate roots in mongoDB? Wouldn't we have to add @Document annotation on top of our Aggregate which would leak infrastructure code in our Domain Model?</p></li>
  </ul>