title: Spring MVC - REST endpoint for inheritance hierarchy
body: <p>I'm using a <code>JOINED</code> inheritance strategy for a class hierarchy which as follows:</p>
  
  <p><code>abstract super class Product</code></p>
  
  <p><code>concrete sub class Type1Product extends Product</code></p>
  
  <p><code>concrete sub class Type2Product extends Product</code></p>
  
  <p>Now i want to make a REST endpoint which allows users to POST data and for it to be parsed as a specific subclass of product, making sure its the same endpoint for any type of product. So something like the following:</p>
  
  <pre><code>@RequestMapping(method = POST, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
      public Product save(@Valid Product product) {
          // ...
          return product;
      }
  </code></pre>
  
  <p>Currently when I try to post I get an error saying I can't initialize an abstract class, since Spring is trying to create a Product instance as opposed to an instance of the correct subtype.</p>
  
  <p>Is what I'm trying to do possible? If not then what is the best practice or convention when making endpoints like this for an inheritance hierarchy?</p>