title: java : advanced inheritance to jpa
body: <p>I have a problem with abstract class where we implement an interface.
  Now the interface is in our implementation of the abstract class other than the other implementation.
  I'll show you the code here:</p>
  
  <pre><code>@MappedSuperclass
  public abstract class AbstractOrder {
      @Id
      @GeneratedValue
      private Long idOrder;
  
      @Temporal(TemporalType.TIMESTAMP)
      @Column(name="datum")
      private Date date = new Date();
  
      @OneToMany(targetEntity=IOrderLine.class)
      private List&lt;IOrderLine&gt; orderLines = new ArrayList&lt;IOrderLine&gt;();
  
      private String refOrder;
      ...
  }
  
  @Entity
  @Table(name="supplyorders")
  public class SupplyOrder extends AbstractOrder implements Comparable&lt;SupplyOrder&gt;, Serializable {
  
      @ManyToOne
      private Supplier supplier;
  
      @Enumerated(EnumType.STRING)
      private SupplyOrderStatus status = SupplyOrderStatus.TOBESUPPLIED;
  
      @ElementCollection
      private Set&lt;CustomerOrder&gt; customerOrders = new HashSet&lt;CustomerOrder&gt;();
      ...
  }
  
  @Entity
  @Table(name="customerorders")
  public class CustomerOrder extends AbstractOrder implements commparable&lt;CustomerOrder&gt;,Serializable {
  
      @ManyToOne
      private Customer customer;
  
      @ManyToOne
      private Place place;
  
      @ManyToOne
      private User vendor;
  
      private double deposit;
  
      @Enumerated(EnumType.STRING)
      private OrderStatus status = OrderStatus.CREATED;
  }
  
  
  
  
  @MappedSuperclass
  public interface IOrderLine {
      double getSubTotal();
      int getQuantity();
      Furniture getFurniture();
  }
  
  @Entity
  @Table(name="supplyorderlines")
  public class SupplyOrderLine implements IOrderLine, Serializable {
  
      @Id
      @GeneratedValue
      private Long id;
  
      @OneToMany
      private List&lt;CustomerOrderLine&gt; customerOrderLines = new ArrayList&lt;CustomerOrderLine&gt;();
      ...
  }
  </code></pre>
  
  <p>and of course a class CustormerOrderLine that implements IOrderLine.</p>
  
  <p>Now for the supplyOrder they have supplyOrderLines in them and the customerOrder has the CustomerOrderLine in them.</p>
  
  <p>The fault we get is that the abstract class doesn't know what implementation to take of the interface IOrderLine.</p>
  
  <p>How can I override the field of orderLines from the abstract class in the implementation class and point to the implementation of the IOrderLine with annotations?</p>
  
  <p>Thx in advance.</p>
  
  <p>Chillworld</p>