-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Explaination of virtual properties declaration
PostPosted: Tue Feb 06, 2007 7:57 am 
Newbie

Joined: Mon Jan 15, 2007 10:09 am
Posts: 12
hi all,

I just want to know why i have to declare properties virtual ???
How is it work ???

Thank you for anwers.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 06, 2007 8:55 am 
Contributor
Contributor

Joined: Sat Sep 24, 2005 11:25 am
Posts: 198
Because nhibernate is creating a proxy of the entity when it is lazy load it, and because NHibernate needs to handle polymorphism correctly, it creates a new instance and forward everything to it.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 06, 2007 8:13 pm 
Newbie

Joined: Mon Aug 21, 2006 9:47 am
Posts: 12
It seems to require virtual keyword for every public member (e.g. for methods as well).

This could be a performance drawback, because there is always a check for an overriden public member by the .Net framework ?
Other thing is, that i might not want to allow every public member in my domain object to be overriden ?

Why is this required for every public member? not for only properties that are descibed in the mapping file?

Just a bit confused and worried,

King Regards,
Taavi


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 07, 2007 5:10 am 
Expert
Expert

Joined: Tue Aug 23, 2005 5:52 am
Posts: 335
Your question was answered by Ayende. NHibernate creates a subclass of your classes as a proxy.

It's a limitation if you want to use proxies. If you turn off all proxying you don't need the virtual keyword (I think), but you'll lose all lazy loading.

Symon.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.