title: JPA return full foreign key entity on Insert/Update
body: <p>My goal is to be able to insert the below object with the user passing in the relevant data and the id of the foreign key, and return back to the user a full object that contains the full foreign key object as well, not just the foreign key id.</p>
  
  <pre><code>@Data
  @Entity
  @EqualsAndHashCode(callSuper = false)
  @Table(name = MY_OBJECT_TABLE)
  public class MyObject {
  
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      @Column(name = "MY_OBJECT_ID", unique = true, nullable = false)
      private Integer myObjectId;
  
      @ManyToOne(targetEntity = ForeignObject.class, fetch = FetchType.EAGER)
      @JoinColumn(name = "FOREIGN_OBJECT_ID", referencedColumnName = "FOREIGN_OBJECT_ID", nullable = false, insertable = false, updatable = false)
      private ForeignObject foreignObject;
  
      @Column(name = "FOREIGN_OBJECT_ID")
      private Integer foreignObjectId;
  
      @Column(name = "RANDOM_FIELD", nullable = false)
      @NotNull
      private Boolean randomField;
  }
  </code></pre>
  
  <p>I was trying with the above and it inserts but it only returns the foreignObjectId on insert and not the entire foreign object.</p>
  
  <p>I tried the below to get it to work but no luck.</p>
  
  <pre><code>    @Transactional
      public MyObject create(MyObject myObject) {
          MyObject createdMyObject = this.myObjectRepository.save(myObject);
          return createdMyObject;
      }
  </code></pre>
  
  <p>and also tried</p>
  
  <pre><code>    @Transactional
      public MyObject create(MyObject myObject) {
          MyObject createdMyObject = this.myObjectRepository.save(myObject);
          return this.myObjectRepository.findById(createdMyObject.getMyObjectId());
      }
  </code></pre>
  
  <p>I'm not sure if there is something in my domain object I need to change or if I need to change my create method in some way.</p>
  
  <p>Current output is:</p>
  
  <pre><code>{
    "myObjectId": 1,
    "foreignObject": null,
    "foreignObjectId": 3,
    "randomField": true
  }
  </code></pre>
  
  <p>Expected output is:</p>
  
  <pre><code>{
    "myObjectId": 1,
    "foreignObject": {
      "foreignObjectId": 3,
    },
    "foreignObjectId": 3, // I don't care if this field stays here or not
    "randomField": true
  }
  </code></pre>