Suppose you have an Employee class and every employee has a set of Skills associated with him. This set may be large enough (say every employee has about 50 skills). In the Employee class mapping you write:
Code:
<set name="skills"
table="XXX"
inverse="true">
<key column="EMPLOYEE_ID"/>
<one-to-many class="Skill"/>
</set>
This works but has one small problem - when you load Employee, Hibernate makes extra effort to load these 50 skills as well to make skills set imeediately available. Not a big problem of course, but probably in the most cases when you are loading Employee, you do not need these skills at all. Skills are required only for very rarely used operations. Why to load them every time? Lazy collection loading helps there. Just by adding lazy="true" attribute you tell Hibernale to postpone loadin of the skill set until it required.
In reverse direction every Skill has association to its employee (it has "employee" property of Employee class. Since Hibernate always tries to load averything associated with requested object, when you try to load one of Skills, Hibernate will load its Employee too. Moreover, when you load large list of Skills matching some criteria (skill name for instance), Hibernate will load Employee for each skill. This is usually a big overkill. You can avoid this by specifying proxy for Employee.
For me personally, it is good to specify lazy="true" for every <set> and to specify proxy for every class (which is not a set element)