I’m trying to figure out if I can make a method that fetches or finds all the entries in a central database I have.
My entities are as follows:
Nomination(Abstract) -> Type1Nomination, Type2Nomination, Type3Nomination, so on.
Nomination has a table is mapped to the DB also, and has the common properties/columns of every type of nomination. The rest is self-explanatory.
The way I see it, I would have to cast the types of nominations to the base class? And this would be done in a Service class (because you cannot make a DAO of an abstract class), am I correct?
You can do this in JPA/Hibernate and JPA inheritance. It should be as simple as querying the Nomination entity.
should return a list of abstract nomination objects.
I’ve seen folks using a type column in conjunction with the
inkeyword to get certain subgroups in your case something likewhere types was a collection of “Type1Nomination” “Type2Nomination” but because these are sibling queries it can lead to some nasty LEFT OUTER JOIN queries