I'm having trouble determining how to map a hierarchy of an embedded class within a hierarchy of entities.
I have a TripEntity class and a specialization of this entity, called a CommercialTripEntity.
The TripEntity contains a class called Itinerary, that is annotated with @Embedded. There is a specialization of the Itinerary class called a CommercialItinerary. CommercialTripEntities therefore contain the specialization of the Itinerary class, CommercialItinerary. An example of this would be:
@Embeddable
@MappedSuperclass
public class Itinerary {
private Date launchDate;
private int people;
...
}
@Entity
public class TripEntity {
@Embedded
private Itinerary itinerary;
...
}
@Embeddable
public class CommercialItinerary extends Itinerary {
private String tourLeader;
...
}
@Entity
public class CommercialTripEntity extends TripEntity {
@Embedded
private CommercialItinerary itinerary;
...
}
Using automatic schema creation of Hyperlink, this is created correctly however trying to persist an entity comes back with an “Wrong Data Type” error that seems to be from it trying to bind the wrong data to field in the database (e.g. a string to a int).
Am I doing something wrong? Is this possible?
Thanks.