title: JPA how to supply inheritance relationships for embeddable objects
body: <p>I have an abstract class "BaseUnit" to represent each unit in my application. I have defined it as <strong>@MappedSuperclass</strong>.</p>
  
  <pre><code>@MappedSuperclass
  public class BaseUnit implements UnitMultiplierInterface, Serializable {
  /**
   * 
   */
  private static final long serialVersionUID = -2648650210129120993L;
  @Enumerated(EnumType.STRING)
  private UnitMultiplier multiplier;
  @Enumerated(EnumType.STRING)
  private UnitSymbol unit;
  @Column(name = "value")
  private double value;
  
  @Override
  public void setMultiplier(UnitMultiplier multiplier) {
      this.multiplier = multiplier;
  }
  
  @Override
  public UnitMultiplier getMultiplier() {
      return multiplier;
  }
  
  @Override
  public void setUnit(UnitSymbol unit) {
      this.unit = unit;
  }
  
  @Override
  public UnitSymbol getUnit() {
      return unit;
  }
  
  @Override
  public void setValue(double currentL1) {
      this.value = currentL1;
  }
  
  @Override
  public double getValue() {
      return value;
  }}
  </code></pre>
  
  <p>I have some subtypes like Percentage, Resistance.</p>
  
  <p><strong>Percentage:</strong> I have defined it as @Embeddable</p>
  
  <pre><code>@Embeddable
  public class Percentage extends BaseUnit {
  /**
   * 
   */
  private static final long serialVersionUID = 2693623337277305483L;
  
  public Percentage() {
      super();
  }
  
  public Percentage(double value) {
      setUnit(UnitSymbol.Percentage);
      setValue(value);
  }
  </code></pre>
  
  <p>}</p>
  
  <p><strong>Resistance:</strong>. I have defined it as @Embeddable</p>
  
  <pre><code>@Embeddable
  public class Resistance extends BaseUnit {
  /**
   * 
   */
  private static final long serialVersionUID = -4171744823025503292L;
  
  public Resistance() {
      super();
  }
  
  public Resistance(double value) {
      setUnit(UnitSymbol.Ohm);
      setValue(value);
  }
  </code></pre>
  
  <p>}</p>
  
  <p>I can use same/different unit type while defining an entity.Here is an example.</p>
  
  <pre><code>@Entity
  public class A implements Serializable {
  /**
   * 
   */
  private static final long serialVersionUID = 5167318523929930442L;
  @Id
  @GeneratedValue
  @Column(name = "id")
  private long id;
  @Embedded
  private Resistance resistance;
  @Embedded
  /** resistance of scenario. */
  private Percentage percentage;
  </code></pre>
  
  <p>}</p>
  
  <p>Now, my question do you think this jpa definitions can work without problem? Or can you please tell me most proper way to achieve my requirement?</p>