I inherited a legacy system where tables are scattered across multiple database servers. I have a DAO that returns User objects. While the user table is in one database it references IDs of properties that are stored in other DBs. For example, jobtitle_ID is in the table but the job_titles table is in another DB on a different server, in a different rdbms (db links are not possible).
I need to hydrate a complete user object so I have been passing in two separate DB connections. This works but I'm not sure if it's appropriate.
The next challenge is that there are several tables in my first DB that reference the jobtitles table. So now I am forced to write almost identical retrieval queries in each DAO to get rows from that table.
I considered extracting the jobtitles retrieval code into its own DAO and passing that into each of the DAOs that use it but this appears to be a no-no as well.
It almost feels like my services need to talk to an intermediary that joins the results of these two DAOs so that it can get a complete User object that includes the job title and not just its ID.
How should I approach this challenge? There is so much built around these databases that I cannot move the jobtitles table.
Aucun commentaire:
Enregistrer un commentaire