title: Hibernate not generating child id on cascade all save
body: <p>Parent Class:</p>
  
  <pre><code>@Entity
  @Table(name = "****")
  @Audited
  public class Ship
  {
      @Id
      @Column(name = "id")
      @GeneratedValue(generator = "uuid")
      @GenericGenerator(name = "uuid", strategy = "uuid")
      private String              id;
  
      @OneToMany(mappedBy = "associatedShip", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
      private List&lt;ShipLoadlineInformation&gt;   loadlineInformation = new ArrayList&lt;ShipLoadlineInformation&gt;(0);
  
      .. with other fields constructors, getters and setters.
  }
  </code></pre>
  
  <p>Child class:</p>
  
  <pre><code>@Entity
  @Table(name = "*********")
  @Audited
  public class ShipLoadlineInformation
  {
      @Id
      @Column(name = "id")
      @GeneratedValue(generator = "uuid")
      @GenericGenerator(name = "uuid", strategy = "uuid")
      private String      id;
  
      @ManyToOne(fetch = FetchType.EAGER)
      @JoinColumn(name = "ASSOCIATED_SHIP")
      private Ship        associatedShip;
  
      .. with other fields, constructors, getter and setters
  }
  </code></pre>
  
  <p>I am saving it in my DAO as follows:</p>
  
  <pre><code>    this.sessionFactory.getCurrentSession().save(ship);
  </code></pre>
  
  <p>When i try to save the object ship its giving me following error:</p>
  
  <blockquote>
    <p>org.hibernate.NonUniqueObjectException: A different object with the
    same identifier value was already associated with the session :
    [com.tms.model.transportMode.ShipLoadlineInformation#]    at
    org.hibernate.engine.internal.StatefulPersistenceContext.checkUniqueness(StatefulPersistenceContext.java:618)
    ~[hibernate-core-4.3.11.Final.jar:4.3.11.Final]   at
    org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.performUpdate(DefaultSaveOrUpdateEventListener.java:301)
    ~[hibernate-core-4.3.11.Final.jar:4.3.11.Final]   at
    org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.entityIsDetached(DefaultSaveOrUpdateEventListener.java:244)
    ~[hibernate-core-4.3.11.Final.jar:4.3.11.Final]   at
    org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:109)
    ~[hibernate-core-4.3.11.Final.jar:4.3.11.Final]   at
    org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:90)
    ~[hibernate-core-4.3.11.Final.jar:4.3.11.Final]   at
    org.hibernate.internal.SessionImpl.fireSaveOrUpdate(SessionImpl.java:684)
    ~[hibernate-core-4.3.11.Final.jar:4.3.11.Final]   at
    org.hibernate.internal.SessionImpl.saveOrUpdate(SessionImpl.java:676)
    ~[hibernate-core-4.3.11.Final.jar:4.3.11.Final]   at
    org.hibernate.engine.spi.CascadingActions$5.cascade(CascadingActions.java:235)
    ~[hibernate-core-4.3.11.Final.jar:4.3.11.Final]   at
    org.hibernate.engine.internal.Cascade.cascadeToOne(Cascade.java:350)
    ~[hibernate-core-4.3.11.Final.jar:4.3.11.Final]   at
    org.hibernate.engine.internal.Cascade.cascadeAssociation(Cascade.java:293)
    ~[hibernate-core-4.3.11.Final.jar:4.3.11.Final]   at
    org.hibernate.engine.internal.Cascade.cascadeProperty(Cascade.java:161)
    ~[hibernate-core-4.3.11.Final.jar:4.3.11.Final]   at
    org.hibernate.engine.internal.Cascade.cascadeCollectionElements(Cascade.java:379)
    ~[hibernate-core-4.3.11.Final.jar:4.3.11.Final]   at
    org.hibernate.engine.internal.Cascade.cascadeCollection(Cascade.java:319)
    ~[hibernate-core-4.3.11.Final.jar:4.3.11.Final]   at
    org.hibernate.engine.internal.Cascade.cascadeAssociation(Cascade.java:296)
    ~[hibernate-core-4.3.11.Final.jar:4.3.11.Final]   at
    org.hibernate.engine.internal.Cascade.cascadeProperty(Cascade.java:161)
    ~[hibernate-core-4.3.11.Final.jar:4.3.11.Final]   at
    org.hibernate.engine.internal.Cascade.cascade(Cascade.java:118)
    ~[hibernate-core-4.3.11.Final.jar:4.3.11.Final]</p>
  </blockquote>
  
  <p>When  debugging it, found out that the id for the parent class is getting generated. But the id for child class is not being generated. </p>
  
  <p>I think this is the cause. Correct me if i am wrong. </p>
  
  <p>Any help is appreciated.</p>
  
  <p>Thanks.</p>