puks7 wrote:
If this feature is not in the current version, then howcome in the manual there is a returnMaps() example? I dont mind using the depricated method as i just want my code to work right now. I can change it once the Hibernate team adds another way of doing this.
Has anyone got the returnMaps example to work? I cant.
I am unable to find any reference to returnMaps() in the code base that I have. May be returnMaps() doesn't work any more so it got removed?
I looked into the code for Criteria queries and Projections and I can't find any code that does similar things that an HQL query with elements() does.
A work around which is not entirely unsatisfactory (performance would be same but you need to do more work) is to do the following.
step1:
select child.id from parent where parent.id = ...
step2:
process each id from the previous result and load them.
This is what HQL query with elements() tag does and Criteria Query is not yet set up to do this. I might end up coding it this way if I think it will not be done in Hibernate in the near future.
The performance is may be bad relatively because you can load all the children properties in the first query itself and build the objects that way like below
step1:
select child.id, child.prop1, child.prop2, ... from parent join child where where child.parent_id = parent.id and ...
step2:
for each result row, construct the child object.
This would reduce the number of queries but the code could be cumbersome and it is better if hibernate can do this.