java - How to to get a concrete class from an hierarchical database structure -


this database structure:

enter image description here

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

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

serialization - Convert Any type in scala to Array[Byte] and back -

SonarQube Plugin for Jenkins does not find SonarQube Scanner executable -