R
Roger Varley
I've been reading about the DAO pattern and I think I understand what
is going on. As I understand it, you use a DAOFactory to return a
DAOManager. The DAOManager handles the connection to the datasource and
the DAOObject class handles the physical transfer between the java
object and the datasource. However all the examples & tutorials I have
found assume that you are working with a single datasource. So you tend
to see code such as
DAOFactory = DAOFactory.getInstance();
DAOManager = DAOFactory.getManager();
DAOObject = DAOManager.getDAOObject(object);
DAOObject.save(object);
How do you handle the situation when the data you require is located in
more than one datasource? You could have the situation where the data
for objectA is in databaseA and the data for ObjectB is in databaseB
or you could be presenting a "composite" view where some of the data
for ObjectC is in databaseA and some is in databaseB.
In the first case the DAOFactory needs to know which DAO manager to
return based on the class to be populated/stored and in the second you
need to return multiple managers (one for each datasource) again
dependant on the object you are trying to store. Or am I confusing
myself?
This scenario arises because I'm trying to intergrate between a new
system and a legacy system each with their own datasources. Over a
period of time the data will move from the legacy system to the new
system and the legacy system will eventually disappear so that I end up
with everything in a single datasource. How do I set up my DAO layer so
that I don't have to rewrite the DAO layer when some data moves from
SystemA to SystemB and rewrite it again when SystemA disappears
altogether.
I hope that this makes sense.
Regards
is going on. As I understand it, you use a DAOFactory to return a
DAOManager. The DAOManager handles the connection to the datasource and
the DAOObject class handles the physical transfer between the java
object and the datasource. However all the examples & tutorials I have
found assume that you are working with a single datasource. So you tend
to see code such as
DAOFactory = DAOFactory.getInstance();
DAOManager = DAOFactory.getManager();
DAOObject = DAOManager.getDAOObject(object);
DAOObject.save(object);
How do you handle the situation when the data you require is located in
more than one datasource? You could have the situation where the data
for objectA is in databaseA and the data for ObjectB is in databaseB
or you could be presenting a "composite" view where some of the data
for ObjectC is in databaseA and some is in databaseB.
In the first case the DAOFactory needs to know which DAO manager to
return based on the class to be populated/stored and in the second you
need to return multiple managers (one for each datasource) again
dependant on the object you are trying to store. Or am I confusing
myself?
This scenario arises because I'm trying to intergrate between a new
system and a legacy system each with their own datasources. Over a
period of time the data will move from the legacy system to the new
system and the legacy system will eventually disappear so that I end up
with everything in a single datasource. How do I set up my DAO layer so
that I don't have to rewrite the DAO layer when some data moves from
SystemA to SystemB and rewrite it again when SystemA disappears
altogether.
I hope that this makes sense.
Regards