Eclipselink 2.6.3 with JPA 2.0
I have an issue with TABLE_PER_CLASS inheritance strategy as you can see I have class A which has @oneToMany mapping with Class Z which has TABLE_PER_CLASS with X and Y as child classes all the classes(X,Y,Z) have same table name i.e TABLE_Z.
When I query on class and I fetch the result of zlist it has same data repeated with all three classes X,Y,Z but I need only class Z as I mentioned in mapping target entity as class Z.
Can anyone point me what I'm doing wrong?
Class A
@Entity
@Table(name="TABLE_A")
@Customizer(ACustomizer.class)
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@ClassExtractor(AExtractor.class)
@InstantiationCopyPolicy
@Cacheable
@Cache( alwaysRefresh=true,
refreshOnlyIfNewer=true,
expiry=300000,
coordinationType = CacheCoordinationType.SEND_NEW_OBJECTS_WITH_CHANGES)
public class A implements Serializable {
@Column(name="ABC")
private String abc;
//the problem is with this relationship...fetches multiple objects for same data with X,Y,Z classes
@OneToMany(cascade=CascadeType.ALL, mappedBy="aobj", targetEntity=Z.class)
private List zlist= new ArrayList<>();
}
Class Z
@Entity
@Table(name="TABLE_Z")
@Customizer(ZCustomizer.class)
@Inheritance(strategy=InheritanceType.TABLE_PER_CLASS)
public class Z{
//some fields
//and @oneToOne mapped with class A
}
class X
@Table(name="TABLE_Z")
@Entity
public class X extends Z{
//some fields
}