@Entity
@Table(name = "t1")
public class Object1 {
  @Id
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  @Column(name = "f_id")
  private Long id;
  @OneToOne(cascade = {CascadeType.ALL},mappedBy = "object1")
  private Object2 object2;
}
@Entity
@Table(name = "t2")
public class Object2 {
  @Id
  @Column(name = "f_id")
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  private Long id;
  @OneToOne
  @JoinColumn(referencedColumnName = "f_id",name = "f_integration_id",insertable = false, updatable = false)
  private Object1 object1;
}
The table t1 has a column f_id which is it's primary key. The table t2 has a column f_integration_id which references to the f_id column in the table t1.
Now when I try to save the Object1 it is creating 2 rows in both tables t1 & t2. But the foreign key column in table t2 is still NULL . Can someone please tell why is this happening ? While it is working like a charm for OneToMany relation.
 
    