title: Bidirectional @OneToOne cascade issue JPA/Hibernate/Spring-Data
body: <p>I have the entities bellow:</p>
  
  <pre><code>@Entity
  public class User implements Serializable {
  
     private String username;
  
     @OneToOne( optional = false, mappedBy = "user", orphanRemoval = true, fetch = FetchType.LAZY, cascade = CascadeType.ALL )
     private BankAccount bankAccount;
     //.....
  }
  </code></pre>
  
  <p>And:</p>
  
  <pre><code>@Entity
  public class BankAccount implements Serializable {
  
      @OneToOne( optional = false, fetch = FetchType.LAZY )
      @JoinColumn( name = "user", unique = true, referencedColumnName = "username" )
      private User user;
      //...
  }
  </code></pre>
  
  <p>For me, I hope I'm right, <code>User</code> entity is the parent so I can cascade its operations to <code>BankAccount</code>. But when I try this : </p>
  
  <pre><code>User user = new User();
  user.setBankAccount(new BanckAccount());
  userRepository.save(user);
  </code></pre>
  
  <p>I have this exception :</p>
  
  <pre><code>org.hibernate.PropertyValueException: not-null property references a null or transient value : org.company.models.User.bankAccount
  </code></pre>
  
  <p>The save cascading is not propagated and I have to save <code>bankAccount</code> before setting it to the user. Am I missing something, should I review my association?
  Thanks</p>