-->
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: Architectural issue
PostPosted: Fri May 11, 2007 4:32 pm 
Newbie

Joined: Fri May 11, 2007 3:29 pm
Posts: 2
Hi,

All the demos of nhibernate I've seen so far have involved grouping the objectname.hbm.xml files in with the project housing the objectname.vb (or .cs) file. In one demo, this was called the business layer. In my estimation, the hbm.xml files contain data layer information.

Ideally, I think there would be a presentation layer (winform or asp.net pages), a business layer (object factories -- business logic and wrappers around data layer calls), a common objects project (class definitions), and a data layer (the only place any data-specific information/code would reside...including the ISession management and hbm files).

This would represent a true 3-tier app with the presentation logic calling the business layer only and the business layer calling the data layer, and all three layers referencing the common objects. In such a scenario, the data layer could be swapped out without having to retool any other layer. Also, maintaining a project with clear separation is much easier.

I tried to set up such a solution with four projects (WEB, BIZ, DAL, and the common OBJ), but I get an NHibernate.MappingException: Resource not found: OBJ.Author.hbm.xml, for example. The Author class is defined in OBJ (common objects project), whereas the Author.hbm.xml file resides in the DAL project. Is there some way of coding the DAL so that it looks for the hbms in the DAL?

Cfg.Configuration.AddClass looks like this in the source, so I am not sure this is possible. This appears to require the .hbm.xml file to reside in the same assembly (project) as the persistentClass (e.g., Author) class definition.

public Configuration AddClass(System.Type persistentClass)
{
return AddResource(persistentClass.FullName + ".hbm.xml", persistentClass.Assembly);
}

Thanks,
David


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 12, 2007 2:43 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Yes, AddClass wants you to follow some conventions. I think this is mentioned in the comments for AddClass. You can add arbitrary .hbm.xml files from any assembly you want by using AddResource. You can also add mapping files from disk using AddFile. See the documentation of Configuration and its class members for more details.


Top
 Profile  
 
 Post subject: Solution
PostPosted: Tue May 15, 2007 3:23 pm 
Newbie

Joined: Fri May 11, 2007 3:29 pm
Posts: 2
Thank you! Your product is very awesome.

Your suggestion was right on. I found an easy solution using Configuration.AddFile.

Dim strPath As String = "H:\...\DAL\"
_config.AddFile(strPath & "Author.hbm.xml")

Thanks again,
David


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.