Let's say we have a couple of classes; Brand and Supplier, where Supplier is a property of Brand.
We have the following
interfaces à la the Controller-Service-Repository
pattern: BrandService, BrandRepository, SupplierService, SupplierRepository.
Within an a
JDBC implementation of BrandRepository, we implement this method:
public Brand find(int brandId). Within this method we retrieve
brand.supplier_id within the SQL query, and we wish- somehow- to use it to set the Supplier property on the Brand object. The most obvious way to do this is to inject a SupplierRepository into the BrandRepository implementation, and just call
public Supplier find(int supplierId) on that.
Do you have strong objections to this? If so, could you outline a preferable alternative?
I'm less interested in the specifics of this example than I am the general principle of whether it's ever okay for a Repository to depend on another.
Many thanks.