NHibernate 2.0 and CSLA 3.6 - virtual public members

NHibernate 2.0 and CSLA 3.6 - virtual public members

Old forum URL: forums.lhotka.net/forums/t/6827.aspx


sturdytree posted on Tuesday, April 21, 2009

I'm starting a project using CSLA.Net 3.6 and NHibernate 2.0.

A first hurdle seems to be NHibernate requiring all public members to be virtual for it to use lazy loading, whereas BusinessBase includes non-virtual members (e.g. IsNew property) . I know I can turn off lazy loading, but assuming I don't want to, are there any workarounds?

At this stage I don't know whether the NHibernate.Mapping.Attributes extension also requires virtual public members for lazy loading but am investigating.

 

sturdytree replied on Tuesday, April 21, 2009

One option I forgot to mention is to simply change the CSLA members to be virtual (there do not appear to be that many changes needed as would make this impractical).

However, the only downside I can think of is there might be a performance penalty for a virtual method as compared to one not marked virtual.

JoeFallon1 replied on Wednesday, April 22, 2009

I have read many threads on NHibernate in the past and they all seemed positive.

My advice:
1. Search for those threads and review them.

2. Do NOT modify CSLA. In the long run you will thank me for this one! Once you begin modifying CSLA then upgrading to the latest version becomes more and more difficult. The goal should be to try and use it "as is".

Joe

sturdytree replied on Wednesday, April 22, 2009

Joe,

Much appreciated - I think I agree amending CSLA would be the last resort!

I have actually searched CSLA forums and Google on the main question on how to get around the fact that Businessbase has non-virtual public properties and NHibernate requires them to be virtual so as to be able to implement lazy loading. Unfortunately, there seems very little comment on this.

I can only think developers must decide to turn lazy loading off (or use their own lazy loading code)?

Kevin Fairclough replied on Wednesday, April 22, 2009

Hi,

I haven't been working on this for a little while, but AFAIK you have to manually do lazy loading, using the pattern suggested by Rocky, which intern means NHibernate needs to manually re-query server-side.

In my hibernate.cfg.xml I have the following at the moment
<property name="use_proxy_validator">false</property>

Regards
Kevin

Copyright (c) Marimer LLC