Due to performance reasons when mapping a 1-M relationship I needed the set of objects to be populated from one sql statement straight away. I set lazy="false" and the set was populated immediately *BUT* using multiple SQL statements. After reading through the reference guide and a general google I was pretty sure fetch="join" was all I needed. However, when I set this I got a HibernateMappingException.
I have worked around it by doing the following.. In my mapping:
On my Criteria object .setFetchMode("batchRequests", FetchMode.JOIN)
It is quite an irritating workaround. What am I doing wrong that I can't set this fetchmode in my hbm.xml
The error is: org.hibernate.MappingException: Error reading resource: XXX.hbm.xml ... Caused by: org.xml.sax.SAXParseException: Attribute "fetch" must be declared for element type "set".
What must I use for set instead then?? I haven't found the reference guide to be very helpful! I really don't want to set the FetchMode each time. So please let me know if you knwo how I can sort this out.