java - Lazy Loading DTO fields in Spring -


I have a project that is using spring and which has broken into a dozen Dao and related DTO. I am using the JDBC template, but not much, because it is absolutely intangible, I am happy.

I am currently lazy loading on my DTO, which keeps some hairy code in their potholes.

The original boilerplate logic is: 1. If the field is not blank then its value and exit 2. Contact the appropriate Dao and obtain relevant DTO 3. Store them till next time.

This works fine except that my lowly DTO has been combined with a whole group of DAo and it is not so.

If I argue in the DAO, then another code appears in the smell because it is loading CRD and lazy to DTO, and as I think the objects should have the same responsibility .

I hope that a relatively simple spring approach is that I can use the injectable laser object injected between DAO and DTO. To get it, but any other solution will work for me

Any ideas?

It is easy to wrap around the DAO around the DAO ... it depends on you How many models would you want to fill. Typically, the use of DTO is not used to bring multiple overs from them, because two or two different databases / Dao calls, in that case you really want ORM since you are looking for an answer to a Dao ... ...

By connecting the DAO together, you are not stopping anything to give you a single DTO, it is easy if you have a DTO associated with DATO. It's not really a service layer, it's just building blocks of DAO. So you can have a person and a telephone number Dao. There may be more one telephone number in a person, so you can also do PersonModelDAo, which uses the person and telephone number Dao under the hood to work. is.

Alternatively, avoid the entire problem and do not attempt the map. 1-N between the person and the telephone number at the DTO level. Just made the right call for your UI right dao. While using DTO I really am better in this way.


Comments