Could I obtain a recommendation to the following problem:
DomesticCat has a vaccinationDate attribute, WildCat does not, it doesn't make sense for him to have one. I need to list all the Cats treated by a VetinaryClinic, and print their potential vaccinationDates. Hence I'd iterate though VetinaryClinic.getAllTreatedCats(), check the type, and if it's a DomesticCat, load the appropriate proxy and fetch the vaccinationDate.
Am I incorrect in the assumption that both DomesticCat and WildCat should be mapped to the same table, but only the DomesticCat exposes vacinatedDate attribute? Should I use something along the lines of:
Cat derivedTypeProxy = (Cat) session.load(Hibernate.getClass(cat), cat.getId());
if (derivedTypeProxy instanceof DomesticCat) {
// can fetch the vaccinationDate
}
Is this the recommended way, am I missing something?
|