Design question --- hibernate# Java - 爪哇娇娃
c*n
1 楼
my model has 2 entities ,
A , B , related 1-1.
normally I do
A a = MyDaoForA.getA() ;
// do something with a
but sometimes right after the above code, I do
B b = a.getB();
so if in the first getA(), I eagerly fetch B too, I would save an
extra SELECT; but in cases where I don't run the latter B, it's a waste to
pull in too many entities through outer JOIN.
so MyDaoForA.getA() should have 2 versions, or even multiple versions, if I
have further C , D associated .....
how do you take care of this?
A , B , related 1-1.
normally I do
A a = MyDaoForA.getA() ;
// do something with a
but sometimes right after the above code, I do
B b = a.getB();
so if in the first getA(), I eagerly fetch B too, I would save an
extra SELECT; but in cases where I don't run the latter B, it's a waste to
pull in too many entities through outer JOIN.
so MyDaoForA.getA() should have 2 versions, or even multiple versions, if I
have further C , D associated .....
how do you take care of this?