I am using a single table inheritance straegy for a table as follows:
Code:
@Entity
@Table(name="SOURCE_VALUE_LINK")
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@IdClass(value=SourceValueLinkPK.class)
@DiscriminatorColumn(name="LINK_TYPE", discriminatorType=DiscriminatorType.STRING)
public abstract class SourceValueLink implements Serializable {
and the subclass is
Code:
@Entity
@DiscriminatorValue("PHON")
public class PhoneValueLink extends SourceValueLink {
private CaseHistory casehistoryphonelink;
...
@ManyToOne
@JoinColumns({
@JoinColumn(name="CASENUM", referencedColumnName="CASENUM" insertable=false, updatable=false),
@JoinColumn(name="VALUE_SEQ_NUM", referencedColumnName="PHON_SEQ_NUM", insertable=false, updatable=false)
})
public CaseHistory getCasehistoryphonelink() {
return casehistoryphonelink;
}
The case History table is lmapped like this
Code:
@Table(name ="CASE_HISTORY")
public class CaseHistory{
private Set<PhoneValueLink> casehistoryphonevaluelink;
...
@OneToMany(mappedBy ="casehistoryphonelink")
public Set<PhoneValueLink> getCasehistoryphonevaluelink() {
return casehistoryphonevaluelink;
}
public void setLocatephonevaluelink(Set<PhoneValueLink> casehistoryphonevaluelink) {
this.casehistoryphonevaluelink = casehistoryphonevaluelink;
}
The subclass is joined to another table as given above.
Now my query is like
Code:
Select new mars.DetailsGrid(lp.psn_pin,lp.seq_num,lp.phone,count(distinct src.srcname),min(src.date_reported),max(src.date_reported),count(src.date_reported)) " +
"From CaseHistory lp Join lp.casehistoryphonevaluelink src "+
"Where lp.casenum = :casenum " +
"Group by lp.casenum,lp.seq_num,lp.phone " +
"Order by max(src.date_reported) desc"
However I get a table not found error. What is my mistake?