title: How should I map my one table to another using JPARepositoy?
body: <p>I have a table schema like this. Notification can be of 2 types : twitter or fb</p>
  <p>For each notification, there will be 1 row in notification table and 1 in either twitter_post/ fb_post.</p>
  <p>Each table have auto sequence id generator.</p>
  <p>FBPost and TwitterPost is mapped via notification_id (PK)</p>
  <p><a href="https://i.stack.imgur.com/8j3do.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8j3do.png" alt="enter image description here" /></a></p>
  <p>I have created entity class like this:</p>
  <pre><code>@Entity
  @Table(name = &quot;notification&quot;)
  public class Notification {
  
      @Id
      @Column(name = &quot;id&quot;)
      @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = &quot;not_id_sequence&quot;)
      private String id;
  
      @Column(name = &quot;description&quot;)
      private String description;
  
      @OneToOne(mappedBy = &quot;notification&quot;)
      private FBPost fbPost;
  
      @OneToOne(mappedBy = &quot;notification&quot;)
      private TwitterPost twitterPost;    
  }
  
  
  @Entity
  @Table(name = &quot;fb_post&quot;)
  public class FBPost {    
      @Id
      @Column(name = &quot;post_id&quot;)
      @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = &quot;post_fid_sequence&quot;)
      private Long postId;
  
      @Column(name = &quot;post_content&quot;)
      private String postContent;
      
      @OneToOne
      private Notification notification;    
  }
  
  
  @Entity
  @Table(name = &quot;twitter_post&quot;)
  public class TwitterPost {
  
      @Id
      @Column(name = &quot;post_id&quot;)
      @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = &quot;post_tid_sequence&quot;)
      private Long postId;
  
      @Column(name = &quot;post_content&quot;)
      private String postContent;
      
      @OneToOne
      private Notification notification;
  
  }
  </code></pre>
  <p>I am using <strong>JpaRepository</strong> to save into the database. But not getting any row into fb_post or twitter_post table.</p>
  <p>Am i doing it wrong in entity class.</p>