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.  [ 3 posts ] 
Author Message
 Post subject: Domain objects and the GAC
PostPosted: Sat Jan 28, 2006 4:30 pm 
Newbie

Joined: Fri Jan 27, 2006 9:03 pm
Posts: 3
I've been developing with NHibernate with a lot of success; however, I am running into trouble when incorporating the GAC.

I have a dll containing my domain and DAOs. An application layer makes use of this domain layer. I want to register the domain layer dll and nhibernate in the GAC. My application can find the DAO dll; however, when the DAO initializes NHibernate, NHibernate fails to find the domain objects (even though they are in the calling DAO assembly), saying it can't find the file.

I think I understand why this doesn't work. NHibernate is using the class name in the mapping file and finds that class via reflection. Since my mapping file is using the partial assembly name (i.e. not the version # and public key), it doesn't search the GAC.

However, I don't know how to work around this (besides not using the GAC). The version number is assigned automatically in the build process, so I don't have the full name available at compiletime. Even if I did, it seems like extreme overkill to have to modify dozens of mapping files on each deployment.


Has anyone else tackled this problem? One method that I thought might be possible would be to modify the embedded xml mapping files at runtime (before instantiating NHibernate, I would do a find/replace on the mapping files). Would this be possible?

I also thought using ILMerge might help, although I haven't tried that yet. I would merge NHibernate with my Domain assembly. Perhaps NHibernate wouldn't even need the partial assemblyname for this. Has anyone tried this? Would there be any sideeffects with regard to how NHibernate accesses the properties/fields on the objects?

Lastly, since I would assume most NHibernate users have their domain objects stored in one assembly, would there be any way to tell nhibernate to search in the calling assembly if none is specified? If not, maybe this would be a worthwhile addition. Even if most users don't put their dlls in the GAC, they could still cleanup their mapping files by not having to specify the assembly in each file.

Even if users don't keep all their domain objects in one assembly, it makes sense that the assembly containing the embedded xml would also contain the objects themselves in nearly all cases. Perhaps NHibernate should default the assembly of an associated object to the assembly containing the object's mapping file.


Thanks for any suggestions,
Trisk


Top
 Profile  
 
 Post subject: Domain Layer Assembly in GAC, hbm.xml mapping problems
PostPosted: Thu Aug 31, 2006 9:59 am 
Newbie

Joined: Thu Aug 31, 2006 9:55 am
Posts: 1
Hi, I'm having the exact same problem, was wondering if anyone had a solution to it.

I was initially thinking of using the NHibernate.Mapping.Attributes but wanted to investiage other options before spending time on that one.

Any information on how to deploy a Domain Layer Assembly that uses NHibernate into the GAC would be appreicated.

Thanks,

Shane


Top
 Profile  
 
 Post subject: Re: Domain objects and the GAC
PostPosted: Thu Aug 31, 2006 10:30 am 
Expert
Expert

Joined: Thu Jan 19, 2006 4:29 pm
Posts: 348
trisk wrote:
I think I understand why this doesn't work. NHibernate is using the class name in the mapping file and finds that class via reflection. Since my mapping file is using the partial assembly name (i.e. not the version # and public key), it doesn't search the GAC.


Maybe NHibernate could have an additional configurations possibility, something like "AssemblyNameSubstitutionMap". When loading HBM files, the assembly name used in mapping would be searched from SubstitutionMap, and if found, the value in map would be used instead. Seems quite trivial to implement....

Gert

_________________
If a reply helps You, rate it!


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