java - dao, tx, service structure: where to place a method querying an abstract entity? -
i have abstract entity 4 other entities inherit from. relationship works well, want query abstract entity entities regardless of types. have no idea place such method since parent entity dao abstract.
entityparent (abstract) -> entitytype1, entitytype2, entitytype3, entitytype4
daos this:
entityparentdao (abstract) -> entitytype1dao, entitytype2dao, entitytype3dao, entitytype4dao
tx this: entityparenttx (abstract) -> entitytype1tx, entitytype2tx, entitytype3tx, entitytype4tx
my project structure goes follows: entities -> dao each entity -> tx each dao -> service combining several txs
there service uses of *tx*s that's within scope of project. criteria/hql query should placed? doesn't sound quite right.
for example let's have car
parent entity , have children entities coupe
, sedan
, minivan
, on , want list of cars given property common , therefore in entity (and table) car
. place query/method given structure i'm following?
i'm not sure follow transaction inheritance, why not make parent dao concrete , add there? long parent entity, , has field, can query on it. return type list of base type, instances of actual type.
ex:
@entity @table(name = "table") @inheritance(strategy = inheritancetype.single_table) @discriminatorcolumn(name = "type", discriminatortype = discriminatortype.integer) public abstract class parentimpl implements parent{} @entity @discriminatorvalue("1") public class entity1impl extends parentimpl {} public interface abstractdao<t extends parent> {} public interface concreteparentdao<parent> {}
Comments
Post a Comment