title: Auto generated id not cascading on EmbeddedId in child entity in Hibernate
body: <p>When trying to insert an Entity - <code>A</code>with a <code>set</code> Another Entity <code>B</code>, <code>B</code> should get the Auto generated <code>Id</code> from <code>A</code> but its <code>null</code>.</p>
  
  <p><strong>Tried and failed:</strong></p>
  
  <ol>
  <li><code>@MapsId("taskPKId.storyId.id")</code> - Same error.</li>
  <li><code>@Embeddable
      class StoryId {
         @ManyToOne(fetch = FetchType.Lazy)
         @JoinColumn(name = "STORY_ID")
         Long id;
      }</code> //Incomprehensible Null pointer exception</li>
  <li><code>mappedBy("story")</code> - same error
  
  <ol start="4">
  <li>Tried with mappedBy('story') but getting an error with repeated column and so had to map it with <code>insertable=false</code> and <code>updatable=false</code> [Hibernate doesn't recognize <code>insertable=false</code> for <code>@EmbeddedId</code>]</li>
  </ol></li>
  </ol>
  
  <p>I am getting <code>STORY_ID = null</code> and therefore <code>saveAll</code> fails on <code>storyRepository.saveAll(stories)</code> where <code>storyRepository</code> is a <strong>Spring Data repository</strong></p>
  
  <pre><code>@Table(name = "STORY")
  @EqualsAndHashCode
  class Story {
     @Id
     @GeneratedValue(stratergy=GenerationType.Auto)
     @Column(name="STORY_ID")
     Long id;
  
     @Column(name="STORY_NAME")
     String name;
  
     //@OneToMany(cascade=ALL, mappedBy="taskPKId.storyId.id", fetch = FetchType.Lazy) // tried this as well
     @OneToMany(cascade=ALL, mappedBy="story", fetch = FetchType.Lazy)
     Set&lt;Task&gt; task;
  }
  
  @Table(name = "TASK_XREF")
  @EqualsAndHashCode
  Class Task {
     @EmbeddedId
     TaskPKId taskPKId;
  
     @Column(name = "TASK_NAME")
     String name;
  
     @ManyToOne (fetch = FetchType.Lazy, optional = false)
     @JoinColumn(name = "STORY_ID", referencedColumnName = "STORY_ID", nullable = false, insertable = false, updatable = false) 
     Story story;
  }
  
  @Embeddable
  @EqualsAndHashCode
  Class TaskPKId  implements Serializable {
     TaskId taskId;
     TaskTypeId taskTypeId;
     StoryId storyId;
  }
  
  @Embeddable
  @EqualsAndHashCode
  class StoryId implements Serializable {
     @Column(name = "STORY_ID")
     Long id;
  }
  </code></pre>
  
  <p><strong>Tables:</strong></p>
  
  <ol>
  <li><strong>STORY</strong> [<code>STORY_ID</code>, <code>STORY_NAME</code>]</li>
  <li><strong>TASK_XREF</strong>  [<code>(TASK_ID(FK), TASK_TYPE_ID(FK), STORY_ID(FK))</code> PK,<code>TASK_NAME</code>]</li>
  </ol>
  
  <p>Story gets inserted (before commit ofcourse), but fails because <code>STORY_ID</code> is sent as null to <code>TASK_XREF</code> for the next inserts</p>