If you just keep the foreign key in the associated class and not the whole B then I think you wont be able to utilize the hibernate association features.
jeybonnet wrote:
But, sometimes, when B and A are not in the same package, I would like to reduce dependency
I think, if A is associated to B then there IS a dependency between the two classes which means the package also need to be dependent or put both the classes in same package. You have to make either of the above decisions rather than avoiding the code dependency when the dependency is there in your business model.
jeybonnet wrote:
Is it a good practice ? Do I keep full B?
So I think you should be keeping the full B
jeybonnet wrote:
Last but not least, If I choose this strategy and if I want to get a list of Products (which are linked to category), and can I write a Find Method where the grid gives me Products details and Category Name. Not easy because A contains only Id to B, not details. So, do I need to find each category ?
Yes you can always write the find method. But as you said this wont be straight forward. You will have to issue an join HQL for getting the Category name of a Product.