Lazy-load conflicts with Property-ref in Many-to-One Mapping

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:

Virtual keyword

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()

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s