I want to create a generic DAO to handle CRUD in my hibernate application. My entities have most associations as LASIA. But I find that hibernation is as efficient as possible with SELECTs, which I need to create several methods for my DAOs. Here is what I mean:
Entity A has two associations. Sometimes I want to get this object without loading associations, and sometimes I want it to be completely populated, so I put two methods in the DAO:
getWhatever()
getWhateverWithLoadedAssociations()
and I would have two different queries: one with no fetch link, and the other with fetch. As a result, sleep mode always makes one choice, whether it is LAZI or not, because I know that I want to get ahead.
The problem with this is keeping SELECT or two, difficulty with adding due to the number of methods.
Is this for extreme? Should I just getWhatever () and just let hibernate make another choice when I need data for an association, although I could save by not doing this SELECT?
Hope this is not too confusing. I am trying to figure out the cost of SELECTS due to lazy loading as well as code complexity.
thank
source
share