-->
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.  [ 5 posts ] 
Author Message
 Post subject: Mapping and classes in a separate assembly
PostPosted: Mon Jan 09, 2006 9:37 am 
Newbie

Joined: Mon Jan 09, 2006 9:29 am
Posts: 3
Folks,

I have a DataLayer assembly that contains all NHibernate mappings as embedded resources, and all data entity classes.

The assembly is called "DataLayer(.dll)", but the namespace is called "MyCompany.AppName.DataLayer".

My problem is: no matter which combinations of assembly and namespace name I try to use in the <configuration>.AddAssembly() calls, it never works. It appears as if NHibernate strictly assumes that the assembly name (the name of the physical DLL file) and the namespace inside that file are going to be the same (and happily mixes the two inappropriately).

As soon as I rename the namespace to be the same as the file name, everything begins to work....

Why this artificial limitation? It's perfectly legal and usually advisable to have a namespace that is DIFFERENT from the actual assembly name - why can't HHibernate (1.0.1) deal with this??

Thanks!
Marc


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 09, 2006 10:21 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
It's not a limitation, it just assumes a certain convention. You can still use AddResource and specify the resources manually if you don't follow the convention.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 09, 2006 12:11 pm 
Newbie

Joined: Mon Jan 09, 2006 9:29 am
Posts: 3
>>You can still use AddResource and specify the
>>resources manually if you don't follow the convention.

Unfortunately, that doesn't seem to be working as expected.

I tried:

Assembly DataLayer = Assembly.Load("DataLayer");
cfg.AddResource("MyCompany.AppName.DataLayer.Employees.hbm.xml", DataLayer);

but I got an error in this case (assembly not found). But according to all I know, you have to specify the RESOURCE NAME, which is <namespace>.<resourcename> and this is what I specified here (yet it seems NHibernate tried to derive the assembly name from the resource name, which fails in this case).

Any ideas?
Marc


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 09, 2006 2:02 pm 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
mschenuer wrote:
Assembly DataLayer = Assembly.Load("DataLayer");
cfg.AddResource("MyCompany.AppName.DataLayer.Employees.hbm.xml", DataLayer);

but I got an error in this case (assembly not found). But according to all I know, you have to specify the RESOURCE NAME, which is <namespace>.<resourcename> and this is what I specified here (yet it seems NHibernate tried to derive the assembly name from the resource name, which fails in this case).


No, NH just passes the resource name to Assembly.GetManifestResourceStream unchanged. Your problem is that either Assembly.Load call failed, or the resource name is wrong.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 09, 2006 5:48 pm 
Newbie

Joined: Mon Jan 09, 2006 9:29 am
Posts: 3
>>No, NH just passes the resource name to
>>Assembly.GetManifestResourceStream unchanged.
>>Your problem is that either Assembly.Load call failed,
>>or the resource name is wrong.

It must have been, yes, sorry 'bout that. Works like a charm now!

Marc


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