Just figured this problem out, I had to remove the property-ref tag from my ‘Many-to-One’ mapping xml file to enable lazy-load working. I am using SQLServer 2005.
From Hibernate forum, some people are having the same problem, but it’s in Hibernate 3 project.
Another thing for lazy-load, all properties in entity/domain object need to set to ‘virtual’.
What’s virtual? Explanation from http://www.dotnettreats.com/tipstricks/oopconcepts2.aspx:
The virtual keyword allows polimorphism too. A virtual property or method has an implementation in the base class, and can be overriden in the derived classes.
To create a virtual member in C#, use the virtual keyword:
public virtual void Draw()
To create a virtual member in VB.NET, use the Overridable keyword:
Public Overridable Function Draw()