java - How to to get a concrete class from an hierarchical database structure -
this database structure:
i have abstractuser
table common properties of role tables: nurse
, doctor
or other roles may added in future.
i event
table use abstract_user_id fk.
i can associated abstractuser
of event
, question how can concrete class of abstractuser
, way can come go through role tables(nurse, doctor, , more), , use fk(abstract_user_id) in tables check if abstractuser.id
exist.
is there better way this?
i ask better ways cause seems have every time when need concrete class abstractuser
, , cannot put method cuz return type not determined. repeat everywhere makes me feel code smell:
abstractuser absuser = event.getabsuser(); if(existinnursetable(absuser)){ nurse n = getnursebyabsuser(absuser); ... //business logic }else if(...){ ... }else{ ... }
Comments
Post a Comment