I have a project that uses Spring and is broken down into several dozen DAOs and related DTOs. I use JdbcTemplate, but not much more, since this is exactly the level of abstraction that I am pleased with.
I am currently doing lazy loading on my DTOs, putting rather hairy code in their getters.
Basic logic: 1. If the field is not null, return its value and exit 2. Contact the appropriate DAO and select the appropriate DTO 3. Keep them until the next time.
It works great, except that my junior DTOs are associated with a number of DAOs and not so POJOeys.
Another smell of code appears if I put the logic in the DAO, since it will handle both CRUD for its DTOs and Lazy Loading, and, as I understand it, objects should have one responsibility.
I hope there is a relatively simple Spring approach that I can use to enter a Lazy Loader object between the DAO and DTO to achieve this, but any other solution will work for me.
Any ideas?
java spring jdbc lazy-loading
Allain lalonde
source share