title: Change subtype in Hibernate Inheritance
body: <p>I have three classes I want to model using Hibernate in Play!Framework:</p>
  
  <pre><code>@Entity
  @Inheritance(strategy = InheritanceType.JOINED)
  public class SupplyArea extends Model {
      public int scadaId;
      public String symbol;
  }
  
  @Entity
  public class HighVoltageSubstation extends SupplyArea {
      public int hvAttribute;
  }
  
  @Entity
  public class MediumVoltageSubstation extends SupplyArea {
      public int mvAttribute;
  }
  </code></pre>
  
  <p>Thanks to Play! I already have defined primary key identifier id.</p>
  
  <p>It works fine most of the time: I've got three database tables, HVSubstation and MVSubstation identifiers are created as foreign keys to SupplyArea and so on.</p>
  
  <p>But I don't 'own' the objects, I need to import them from another source. Then, if something changes in another application, I need to update mine. The problem is when the object changes its type: it is no more a HVSubstation, it is now a MVSubstation. All other parameters (ie. scadaId, symbol) remain the same. It is the same object, but has another type.</p>
  
  <p>Is there any way to switch between subtypes without losing my primary key identifier? I tried something like this:</p>
  
  <pre><code>SupplyArea oldArea = SupplyArea.getByScadaId(scadaId); // returns HVSubstation
  SupplyArea newArea = new MVSubstation();
  newArea.id = oldArea.id;
  newArea.scadaId = scadaId;
  newArea.symbol = symbol;
  oldArea.delete();
  newArea.save();
  </code></pre>
  
  <p>Obviously, it does not work.</p>