Hello everyone,
Is there any way of mapping a many-to-one relationship as lazy without using a proxy for the related class?
My motivation is:
1. I have a class with many many-to-one relationships
2. I usually work with only one of those at a time
3. The related classes are also used alone (e.g. I use find() and HQL to query those classes)
4. I don't want an SQL query for each instance of the related classes when finding for a list of instances (and that's what I get when I do a find() over a class with a proxy).
I've read in the documentation (I don't remember exactly where) that find() is supposed to NOT use proxies, but it uses proxies in my tests.
I'm using Hibernate 2.0, and my class doesn't have any special thing (a class mapped with proxy attribute to itself):
Code:
<class name="Person" table="PERSON" proxy="Person" >
<id name="id" type="string" >
<column name="PERSON_ID"/>
<generator class="assigned"/>
</id>
(...)
</class>
Am I missing something? Is there a better solution I havn't seen?
Thanks in advance,
Jordi Pradel