mclenaghan,
Were you able to find a solution to your problem? I have something similar going on. Coding to interfaces, I have the following (a silly example, but the real example's more complex):
Code:
public interface SupportsTermination {
void setTermDate(Date date);
Date getTermDate();
}
public class Teacher implements SupportsTermination {
long id;
String name;
Date startDate;
Date endDate;
...
public void setTermDate(Date date){
this.endDate = date;
}
public Date getTermDate(){
return this.endDate;
}
}
public class Janitor implements SupportsTermination {
long id;
String name;
Date startDate;
Date endDate;
...
public void setTermDate(Date date){
this.endDate = date;
}
public Date getTermDate(){
return this.endDate;
}
}
The idea being that a termination service would be able to perform terminations for any type that implements TerminationAware.
I initially intended to utilize implicit polymorphism, expecting that the following query might work (I'm using Spring's HibernateTemplate) without any additional mapping:
Code:
List<TerminationAware> terms = this.hibernateTemplate
.find("from TerminationAware");
But I get the following error message:
Quote:
org.hibernate.hql.ast.QuerySyntaxException: TerminationAware is not mapped [from TerminationAware]
So it seems some mapping is necessary. I've read over this section of the reference manual
http://www.hibernate.org/hib_docs/v3/reference/en/html_single/#inheritance-strategies several times, but I'm still unclear on how to map this interface.
Any suggestions would be greatly appreciated!
Thanks,
Leo