-->
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.  [ 12 posts ] 
Author Message
 Post subject: Running nhibernate in medium trust, help needed..
PostPosted: Sat Sep 02, 2006 6:31 pm 
Newbie

Joined: Sat Sep 02, 2006 6:22 pm
Posts: 1
Location: Stockholm, Sweden
Hi. I downloaded and modified a cms tool called Cuyahoga to suit my needs for a customer of mine.
At this time I wasn't even aware of the tool using NHibernate, but it does.
The problem is that my web host only allows medium trust, while NHibernate seem to require full trust.
I found some posts in the forums about using ILDasm and other tools but none of the descriptions are thorough enough for me to be able to comprehend them, considering I have no prior knowledge of NHibernate, or even how to program for NHibernate. I just want to get the site running on my webhost... :)
I tried to download the 1.2.0 alpha 1 which, according to some forum users, resolve the issue of full trust, but once I have replaced the binaries for
Castle.DynamicProxy.dll
Iesi.Collections.dll
log4net.dll
NHibernate.Caches.SysCache.dll
NHibernate.dll
Nullables.dll
Nullables.NHibernate.dll
nunit.framework.dll
and then successfully recompiled the application, i instead get:

Type 'Cuyahoga.Core.Domain.CustomMenu' cannot be specified as proxy: method get_Id should be virtual
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: NHibernate.InvalidProxyTypeException: Type 'Cuyahoga.Core.Domain.CustomMenu' cannot be specified as proxy: method get_Id should be virtual

Source Error:

Line 90: Configuration config = new Configuration();
Line 91: this._nhibernateConfiguration = config.AddAssembly(this.GetType().Assembly);
Line 92: this._nhibernateFactory = this._nhibernateConfiguration.BuildSessionFactory();
Line 93: }
Line 94: }


Source File: C:\DEV\Projects\Websites\Cuyahoga\Core\Service\SessionFactory.cs Line: 92


This, to me, looks like the implementation in the new version has changed, and is not backwards compatible?

What should I do, Im at a loss here, and Im having a customer getting more and more frustrated...

Any help is greatly appreciated! Sort of desperate here....


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 03, 2006 7:21 am 
Senior
Senior

Joined: Sat May 14, 2005 8:40 am
Posts: 130
Since NHibernate 1.2.0, objects are lazy by default. This requires all public members to be virtual. This can be changed by setting default-lazy="false" in <hibernate-mapping>.

Could you keep us posted with your experiences? I'm very eager to know if things finally will work in a Medium Trust environment.

_________________
Cuyahoga


Top
 Profile  
 
 Post subject: NHib1.2.0 alpha error: method get_Id should be virtual
PostPosted: Tue Sep 19, 2006 9:24 am 
Newbie

Joined: Wed Nov 16, 2005 6:47 am
Posts: 6
I try to use version 1.2.0 alpha 1
with objects and Xml maps created by MyGeneration (tried with any template available)

I just run a test project on Visual Studio (not the same topic as "Medium Trsut" posted this far) and got the

Exception Details: NHibernate.InvalidProxyTypeException: Type 'Mylib.xxx' cannot be specified as proxy: method get_Id should be virtual

MyGeneration generates data classes that are sealed, hard to make a method virtual in that case.

how to resolve?

the same classes and hbm work fine with nhibernate-1.0.2.0


guillaume.

_________________
Guillaume Saint-Etienne


Top
 Profile  
 
 Post subject: Re: NHib1.2.0 alpha error: method get_Id should be virtual
PostPosted: Tue Sep 19, 2006 9:29 am 
Senior
Senior

Joined: Sat May 14, 2005 8:40 am
Posts: 130
yohm31 wrote:
Exception Details: NHibernate.InvalidProxyTypeException: Type 'Mylib.xxx' cannot be specified as proxy: method get_Id should be virtual

MyGeneration generates data classes that are sealed, hard to make a method virtual in that case.

how to resolve?


I don't know MyGeneration too well, but I can't imagine that there isn't some way to change the templates so that public members are virtual and the classes aren't sealed anymore.

_________________
Cuyahoga


Top
 Profile  
 
 Post subject: Re: NHib1.2.0 alpha error: method get_Id should be virtual
PostPosted: Tue Sep 19, 2006 10:09 am 
Expert
Expert

Joined: Thu Jan 19, 2006 4:29 pm
Posts: 348
yohm31 wrote:
Exception Details: NHibernate.InvalidProxyTypeException: Type 'Mylib.xxx' cannot be specified as proxy: method get_Id should be virtual

MyGeneration generates data classes that are sealed, hard to make a method virtual in that case.

how to resolve?

the same classes and hbm work fine with nhibernate-1.0.2.0


Nhibernate 1.2 changed default value of "lazy" attribute from false to true. Plus, it added sanity check that lazy classes must have only virtual public members.

So, eitrher specify lazy="false" for all class mappings, or make You classes unsealed with only virtual public members.

Gert

_________________
If a reply helps You, rate it!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 18, 2006 11:14 am 
Newbie

Joined: Wed Sep 13, 2006 4:30 pm
Posts: 4
What does have the virtual keyword has to do with the lazy loading?

I have my class define like that:

public class MyClass
{

private string _title;
public string Title
{
get;
set;
}
}

does that make MyClass sealed since I didnt declare my property as virtual?
and if so, what's the difference for developper using my class and what's relating this with nhibernate?

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 18, 2006 11:28 am 
Expert
Expert

Joined: Thu Jan 19, 2006 4:29 pm
Posts: 348
theflamme wrote:
What does have the virtual keyword has to do with the lazy loading?


NHibernate creates dynamically a inherited class, an overrides all virtual members. In those overrides, it checks if the data is loaded or not.

If any of public members is not virtual, the data might remain unloaded if the instance is used.

theflamme wrote:
does that make MyClass sealed since I didnt declare my property as virtual?

Sealed is C# keyword:
Code:
public sealed class Child
means that the class can not be inherited from.

theflamme wrote:
and if so, what's the difference for developper using my class and what's relating this with nhibernate?

If developer uses class, the virtual/non-virtual/selaed should not make difference. If he/she inherits from the class, the usual differences apply. (You can override virtual methods; You can not inherit from sealed class)

Gert

_________________
If a reply helps You, rate it!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 03, 2007 2:27 pm 
Newbie

Joined: Wed Jan 03, 2007 2:24 pm
Posts: 2
Hey guys -- just moving into using 1.2 myself.

I have been using codesmith to generate my classes and mapping files. I have updated the NHibernate templates for codesmith to generate 1.2 compliant files and also updated them to work with nullable types and uniqueidentifier (GUID) Id's

If you guys want them let me know. I'm not an NHibernate expert by any means and I'd love input on my codesmith template updates. I'm sure they are far from complete..

_________________
______________________________
livesN[box]


Top
 Profile  
 
 Post subject: NHibernate 1.2 templates
PostPosted: Fri Jan 05, 2007 5:05 pm 
Newbie

Joined: Fri Jan 05, 2007 5:01 pm
Posts: 1
livesNbox,

Could you send me the NHibernate 1.2 codesmith templates? My email is thinrichs{at}amphire.com

Thanks for your help!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 05, 2007 5:44 pm 
Newbie

Joined: Wed Jan 03, 2007 2:24 pm
Posts: 2
Sure thing.. sending now.. let me know what you think..

_________________
______________________________
livesN[box]


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 14, 2007 9:24 am 
Newbie

Joined: Sun Jan 14, 2007 8:36 am
Posts: 3
livesNbox wrote:
Sure thing.. sending now.. let me know what you think..


if it can help , i'm at the same level as you guys I think , i'm just moving to 1.2 and using the codesmith templates.

At the moment I'm trying to get the bags changed by sets (generic) to have generic collections in my classes.

best!


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 14, 2007 9:42 am 
Newbie

Joined: Sun Jan 14, 2007 8:36 am
Posts: 3
livesNbox wrote:
Hey guys -- just moving into using 1.2 myself.

I have been using codesmith to generate my classes and mapping files. I have updated the NHibernate templates for codesmith to generate 1.2 compliant files and also updated them to work with nullable types and uniqueidentifier (GUID) Id's

If you guys want them let me know. I'm not an NHibernate expert by any means and I'd love input on my codesmith template updates. I'm sure they are far from complete..


lives, did you managed to get the generic list in a class to work with set or map ???

thanks? can u send me your templates ? gonna check them out , thanks !

wimvandenbroeck@telenet.be


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 12 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.