title: Hibernate unidirectional one to one
body: <p>I have two classes</p>
  
  
  
  <pre><code>class Point {
  
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      @Column(name = "point_id")
      private Long id;
  
      @Column(name = "name")
      private String name;
  }
  </code></pre>
  
  
  
  <pre><code>class Link {
  
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      @Column(name = "link_id")
      private Long id;
  
      @Column(name = "name")
      private String name;
  
      @OneToOne
      @JoinColumn(name = "fp_id")
      private Point firstPoint;
  
      @OneToOne
      @JoinColumn(name = "sp_id")
      private Point secondPoint;
  }
  </code></pre>
  
  <p>If I remove Link I get constraint error.
  I want to get the following functionality:</p>
  
  <ol>
  <li>remove Point -> Link removed automatically</li>
  <li>remove Link -> Point didn't remove automatically</li>
  </ol>
  
  <p>How to configure this relation? </p>
  
  <p><strong>UPDATE</strong>
  Diagram of DB</p>
  
  <p><img src="https://i.stack.imgur.com/D8WbS.png" alt="Diagram of DB"></p>