NHibernate and tt.dom

Jul 13, 2011 at 7:24 PM

Hello,

I installed tt.dom and everything worked as expected.

Now I wanted to use NHibernate and tt.dom together.

But I cannot create NHibernate Mappings for Classes that inherit from DataObject

I always get an NHibernate exception at startup saying that

"The following types may not be used as proxies:Edikte.Model.Edikt: method add_UndoListChanged should be 'public/protected virtual' or 'protected internal virtual'Edikte.Model.Edikt: method remove_UndoListChanged should be 'public/protected virtual' or 'protected internal virtual'Edikte.Model.Edikt: method add_RedoListChanged should be 'public/protected virtual' or 'protected internal virtual'Edikte.Model.Edikt: method remove_RedoListChanged should be 'public/protected virtual' or 'protected internal virtual'Edikte.Model.Edikt: method add_BeginEditItem should be 'public/protected virtual' or 'protected internal virtual'Edikte.Model.Edikt: method remove_BeginEditItem should be 'public/protected virtual' or 'protected internal virtual'Edikte.Model.Edikt: method add_CancelEditItem should be 'public/protected virtual' or 'protected internal virtual'Edikte.Model.Edikt: method remove_CancelEditItem should be

.... and some errors more...

virtual'Edikte.Model.Edikt: method set_ValidationRules should be 'public/protected virtual' or 'protected internal virtual'Edikte.Model.Edikt: method get_PermissionProvider should be 'public/protected virtual' or 'protected internal virtual'Edikte.Model.Edikt: method set_PermissionProvider should be 'public/protected virtual' or 'protected internal virtual'Edikte.Model.Edikt: method get_Error should be 'public/protected virtual' or 'protected internal virtual'"

 

Does anybody know why this doesn't work?

Am I doing something wrong? 

Has anybody tried to use NHibernate and tt.dom together?

Thanks for help

Greetings from Vienna

Wolfgang Muellauer

Jul 14, 2011 at 11:16 AM

Hello,

at the moment I'm trying to achieve the same using Entity Framework and Jörg Neumann gave me an hint: Use the proxies provided by TT.DOM to cope with your O/R-Mapper Objects. So I started having a look at the Proxy-Demo project which is contained in the samples you can download from here. A short tip: Follow this link: http://headwriteline.blogspot.com/2010/03/ttdom-runtime-proxies.html ;-)

Regards,

M. Seeger

Jul 14, 2011 at 11:21 AM

Hi Wolfgang,

I don't know what NHibernate does exactly, but I think it tries to generate a runtime proxy for the object via inheritance. Therefore the members must be virtual.

Try to make all public/protected members of DataObject virtual. Another way is to generate a TT.DOM-runtime proxy for the NHibernate-objects (which dosn't inherits from DataObject in this case).

Hope it helps,

Jörg

Jul 15, 2011 at 11:18 AM
Edited Jul 17, 2011 at 8:09 PM

Hello, Jörg!

 Thank you for your help!

I will try to modify the source and make all members of DataObject virtual this seems more comfortable
than working with one more runtime- proxy.
I will inform you about my success or failure with NHibernate.
Sometimes multiple inheritance would be a great feature.......

 Greetings from Vienna

 Wolfgang

 

Jul 17, 2011 at 10:15 PM

Hello, Joerg, 
Hello,  M. Seeger

Thank you for your help. 
I just want to tell you that I have managed to use NHibernate together with DataObject.

As Joerg suggested, I modified the class DataObject. I made all events and
properties virtual and internal protected. With these modifications I could
compile my application.

 Wolfgang