title: JPA entity relations are not populated after .persist()
body: <p>this is a sample of my two entities:</p>
  
  <pre><code>@Entity
  public class Post implements Serializable {
      @OneToMany(mappedBy = "post", fetch = javax.persistence.FetchType.EAGER)
      @OrderBy("revision DESC")
      public List&lt;PostRevision&gt; revisions;
  
  @Entity(name="post_revision")
  public class PostRevision implements Serializable {
      @ManyToOne
      public Post post;
  
      private Integer revision;
  
      @PrePersist
      private void prePersist() {
          List&lt;PostRevision&gt; list = post.revisions;
  
          if(list.size() &gt;= 1)
              revision = list.get(list.size() - 1).revision + 1;
          else
              revision = 1;
      }
  </code></pre>
  
  <p>So, there's a "post" and it can have several revisions. During persisting of the revision, entity takes a look at the list of the existing revisions and finds the next revision number. Problem is that Post.revisions is NULL but I think it should be automatically populated. I guess there's some kind of problem in my source code but I don't know where. Here's my "persistence" code:</p>
  
  <pre><code>Post post = new Post();
  PostRevision revision = new PostRevision();
  revision.post = post;
  
  em.persist(post);
  em.persist(revision);
  em.flush();
  </code></pre>
  
  <p>I think that after persisting "post", it becomes "managed" and all the relations should be populated from now on.</p>
  
  <p>Thanks for help!</p>
  
  <p>(Note: public attributes are just for demonstration)</p>