Hi Derek,
Derek Broughton wrote:
Rob Hills wrote:
I'd
be looking to empower a Manager class with the wherewithall to do the
job. I'd create a Manager class for your unnamed third object (UTO) and
give it access to the DAO(s) it needs to load/create/persist the UTOs
and return them to your Action.
That's what I was suspecting I must need to do, but I'm still having trouble
figuring out how I give a manager access to other DAOs. The Manager
constructor gets a DAO for it's own object, but how does it access any
other object's DAO?
Ah, that bit's quite easy. Simply add the relevant DAOs to your Manager
as attributes, give them public setters and Spring will do the rest,
injecting the live DAOs at runtime, assuming you've defined the DAOs as
beans in your applicationContext.xml file.
Make sure your DAO attributes are references to the Interface rather
than the Hibernate implementation. For example, if you've got a UtoDao
interface and a UtoDaoHibernate class, your manager should include
something like this:
UtoDao utoDao;
public void setUtoDao(UtoDao utoDao) {
this.utoDao = utoDao;
}
Then you just use the utoDao attribute in your manager wherever you need it.
HTH,
Rob Hills
Waikiki, Western Australia
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]