title: One method to save entity which extand abstract class in repository
body: <p>I am new at abstract class as Entity so for training I created abstract class</p>
  <pre><code>@Entity
  @Inheritance(strategy = TABLE_PER_CLASS)
  @Getter
  @Setter
  @NoArgsConstructor
  public abstract class ShapeEntity {
       @Id
       @GeneratedValue(generator = &quot;system-uuid&quot;)
       @GenericGenerator(name = &quot;system-uuid&quot;, strategy = &quot;uuid&quot;)
       private String id = UUID.randomUUID().toString();
  }
  </code></pre>
  <p>and classes which extand Shape:</p>
  <pre><code>public class SquareEntity extends ShapeEntity {
      ...
  }
  public class CircleEntity extends ShapeEntity {
      ...
  }
  </code></pre>
  <p>every entity has repostiory like that:</p>
  <pre><code>public interface CircleEntityRepository extends JpaRepository&lt;CircleEntity, String&gt; {
  }
  </code></pre>
  <p>When I want to update entity I am searching it in every repository, next (if entity was found) map parameters and finnaly have to save that entity in database.
  How can I easy decide which repository should be used for it? I created method save with if else which now works:</p>
  <pre><code>public ShapeEntity save(ShapeEntity shapeEntity) {
      if (shapeEntity.getClass().getName().contains(&quot;CircleEntity&quot;)) {
          return circleEntityRepository.save((CircleEntity) shapeEntity);
      } else if (shapeEntity.getClass().getName().contains(&quot;SquareEntity&quot;)) {
          return squareEntityRepository.save((SquareEntity) shapeEntity);
      } else {
          throw new EntityNotFoundException();
      }
  }
  </code></pre>
  <p>but it is a bit uncomfortable becouse when I will have 20 entities I will have to create 20 else if loops. Can I do any interface for this or something like that?</p>