title: OneToOne PrimaryKeyJoinColumn Cascade
body: <p>I am struggling a little bit to make Eclipselink to cascade persist a relationship:</p>
  
  <pre><code>@Entity
  class Notification {
      @Id
      @UuidGenerator(name="UUID_GEN")
      @GeneratedValue(generator="UUID_GEN")
      @Column(name = "NOTIFICATION_ID")
      private UUID id;
  
  
      @OneToOne(cascade = ALL, fetch = FetchType.EAGER)
      @JoinFetch(JoinFetchType.INNER)
      @PrimaryKeyJoinColumn(name="NOTIFICATION_ID", referencedColumnName="NOTIFICATION_ID")
      private Notificator notificator;
  
     ...
  }
  
  @Entity
  class Notificator {
  
      @Id
      @Column(name="NOTIFICATION_ID")
      private UUID id;
  
      ...
  }
  </code></pre>
  
  <p>So when i tried to persist a Notification object, Eclipselink failed to persist the enclosing Notificator object, because the Notificator.id was not set, so a constraint failure has happened.</p>
  
  <p>In a second attempt, i tried to use @MapId annotation:</p>
  
  <pre><code>@Entity
  class Notification {
      @Id
      @UuidGenerator(name="UUID_GEN")
      @GeneratedValue(generator="UUID_GEN")
      @Column(name = "NOTIFICATION_ID")
      private UUID id;
  
  
      @OneToOne
      @MapsId
      private Notificator notificator;
  
     ...
  }
  
  @Entity
  class Notificator {
  
      @Id
      @Column(name="NOTIFICATION_ID")
      private UUID id;
  
      @OneToOne
      PrimaryKeyJoinColumn(name="NOTIFICATION_ID", referencedColumnName="NOTIFICATION_ID")
      private Notification notification; // didn't need to have it here, but fine.
      ...
  }
  </code></pre>
  
  <p>This way, i couldn't even bring EntityManager. It throws this error:</p>
  
  <blockquote>
    <p>Exception Description: A non-read-only mapping must be defined for the
    sequence number field.</p>
  </blockquote>
  
  <p>Is there a way to make this cascade to work so i don't need to persist the two entities separately? I am trying to avoid this, since there are a few other entities sharing this same ID, so it would be kind of a dirty work as it stands.</p>
  
  <p>Thank you</p>