title: Spring Data JPA @EntityListeners w/ @Transient @PostLoad, Properties Not Updated
body: <p>We have two Spring Data JPA Entities (parent,child), the count of children with a field set to a particular value, influences the value of a parent's record in a <code>@Transient</code> property set during <code>@PostLoad</code></p>
  
  <p>Parent:</p>
  
  <pre><code>@Entity
  public class Parent {
     @Transient
     private boolean status = false;
  
     @OneToMany
     @Where("STATUS = true")
     private Set&lt;Children&gt; childrens;
  
     @PostLoad
     public void postload(){ 
       if(childrens.size() &gt; 0) this.status = true;
     }
  ....
  } 
  </code></pre>
  
  <p>Children:</p>
  
  <pre><code>@Entity
  @EntityListeners({ ParentListener.class })
  public class children {
  
        private Boolean status = false;
  
        @ManyToOne
        private Parent parent;
  }
  </code></pre>
  
  <p>In my controller / service classes (which are <em>NOT</em> annotated as <code>@Transactional</code>, I come along and update the status value of a <code>Children</code> record: </p>
  
  <pre><code>@Service 
  public class ChildrenService {
  
  ...
      public void doStuff(Children child) {
          child.status = true;
          childRepository.save(child);
      }
  } 
  </code></pre>
  
  <p>Now the <code>ParentListener</code> kicks in, and I want to log when the parent's status value changes.</p>
  
  <pre><code>class ParentListener {
  
      @PostUpdate // AFTER Children record updated
      public void childPostPersist(Children child) {
           AutowireHelper.autowire(this);
           // here child.parent.status == false (original value)
           // but I have set this child record equal to true, and 
           // have triggered the `save` method, but assuming I am still
           // in the session transaction or flush phase, the 
           // parent related record's status is not updated?
           System.out.println(child.parent.status); // prints false
           Parent currentParent = parentRepository.getOne(child.parent.getId());
           System.out.println(currentParent.status); // prints false
      }
  }
  </code></pre>
  
  <p><em>What am I misunderstanding about <code>@Transactional</code>, <code>@Postload</code> and transactions/sessions and <code>EntityListeners</code>?</em></p>
  
  <p>PS. AutowireHelper is reference from <a href="https://stackoverflow.com/questions/47941717/spring-dependency-injection-into-jpa-entity-listener/48063894#48063894">here</a></p>