Is there a way to establish a OnetoMany relationship with only the subclass of TablePerHierarchy mapped entity?
I have an entity class A mapped as a table per hierarchy strategy. There is a class B that is assiciated with only one of the subclasses of class A. When I establish the OnetoMany from class B to one of class A's subclasses I get a classcastexception because the generated query does not filter on the subclass but still returns all records regardless of type. Here are the class mappings:
@Entity
@Table(name = "FBPROPERTY")
public class PropertyVO
{
...
@OneToMany
@JoinColumns( { @JoinColumn(name = "itemid", referencedColumnName = "propertyid") })
public Set<PropertyLineItemLienVO> getLineItemLiens()
{
return lineItemLiens;
}
}
@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "TYPEID", discriminatorType = DiscriminatorType.INTEGER)
@Table(name = "FBLINEITEMLIENS")
@Name("lineItemLienVO")
public class LineItemLienVO implements Serializable
{
...
}
@Entity
@DiscriminatorValue("1")
@Name("propertyLineItemLien")
public class PropertyLineItemLienVO extends LineItemLienVO implements Serializable
{
.....
}