I have an abstract entity that 4 other entities inherit from. This relationship works well, however I want to query the abstract entity so that I get all entities regardless of their types. I have no idea where to place such a method since the parent entity dao is also abstract.
EntityParent (abstract) -> EntityType1, EntityType2, EntityType3, EntityType4
DAOs look like this:
EntityParentDAO (abstract) -> EntityType1DAO, EntityType2DAO, EntityType3DAO, EntityType4DAO
TX also look like this:
EntityParentTx (abstract) -> EntityType1Tx, EntityType2Tx, EntityType3Tx, EntityType4Tx
My project structure goes as follows:
Entities -> DAO for each entity -> TX for each DAO -> Service combining several TXs
There is Service which uses all of the *TX*s that’s within the scope of my project. Is this where a criteria/HQL query should be placed? That doesn’t sound quite right.
For example let’s say I have a Car parent entity and that I have children entities Coupe, Sedan, Minivan and so on and I want a list of cars given a property that is common to all and therefore in the entity (and it its table) Car. Where would I place this query/method given the structure I’m following?
I’m not sure I follow the transaction inheritance, but why not make the parent dao concrete and add it there? As long as the parent is an Entity, and it has the field, you can query on it. The return type will be a list of the base type, but it will be instances of the actual type.
Ex: