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
As I thought it should be:
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.
Thanks!!
pascal betz
Ranch Hand
Joined: Jun 19, 2001
Posts: 547
posted
0
can you post your full mapping ? sounds like something is wrong with the DTD you are using ??? according to the DTD the fetch attribute is valid for the set element: http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd (search for "ELEMENT set")