I have the following situation:
Code:
Bank.address (n:1)
(1:1) Address.bank
Address.country (n:1)
(1:1) Country.address
My query looks like this:
Code:
Criteria c = session.createCriteria(Bank.class);
c.setFetchMode("address.country", FetchMode.EAGER);
c.list();
The problem is that the Address-Object has two additional 1:1 associations which must be loaded by Hibernate in order to initialize an instance of Address. That's pretty stupid for a query, resulting in (n*2)+1 queries.
Is there any way how I can achieve the same result *without* the number of 'post-processing'-queries ?
I just want the Bank, the Address and the Country. Everything else can be null without any problem.
I tried to add additional path elements to setFetchMode, but it seems that they were ignored (strangely I can type whatever I want in the path, no errors, it's just ignored).