-->
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.  [ 2 posts ] 
Author Message
 Post subject: Loading private classes in one-many relationships
PostPosted: Thu Jan 11, 2007 7:05 pm 
Newbie

Joined: Thu Jan 11, 2007 6:16 pm
Posts: 1
I have a number of private business classes that all implement public interfaces. The classes can be created in client code through a public factory class.

I have set up my hibernate mapping files (to use the classes and not the interfaces) and can succesfully load the private class. However as soon as I add the <many-to-one> section to link the classes / tables I get an exception when it tries to load a linked class.

"Creating a proxy instance failed"
Inner exception = "Access is denied: 'Namespace.LinkClass'.":""

As soon as I make the link class public the exception goes away.

It strikes me as odd that Hibernate is able to create the main class OK even though it is private, but struggles to create the link class. Is this a bug / limitation of NHiibernate (I have tested this on 1.2.0Beta 1 and Beta 3) or am I doing something wrong.

I don't really want to make the class public as I would prefer my design to have only the interfaces public. My business logic lives in one assembly and my persit / hibernate logic lives in a second assembly. I have tried using the InternalsVisible attribute on my business assembly but this does not solve the problem.

Any help would be much appreciated.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 12, 2007 4:35 am 
Contributor
Contributor

Joined: Sat Sep 24, 2005 11:25 am
Posts: 198
The issue here is with the proxy, actually.
NH is actually create a subclass of this in runtime, and it is failing because the class is private.
If you are on .Net 2.0, try defining the classes as internal, and then specify:

Code:
[assembly: InternalsVisibleTo("DynamicAssemblyProxyGen, PublicKey=0024000004800000940000000602000000240000525341310004000001000100fb4ff5a7c8bba6feb6a6b75b260cd57c1b8b85b63a45dedcb7081331740c870852af30abd2a74700cce1d7a01aeed019339db202e010ac808396b2922362877c6afc8993281092434a223b9920cac8ba409d138a97b73cd1baad813af450b886e3d7f5a09ee450d415145eb0524778a6bd1ae733fd2b6ceebfd151620534bcb7")]


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