-->
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.  [ 4 posts ] 
Author Message
 Post subject: hbm.xml mapping with .Net 2.0
PostPosted: Tue Apr 11, 2006 10:15 am 
Newbie

Joined: Tue Apr 11, 2006 9:59 am
Posts: 3
Can someone point me towards documentation explaining how to convert my hbm.xml mapping files to Asp.Net 2.0?

I did see one other post on here concerning this but the only reply stated "add your .hbm and .cs files to a separate class library project and reference that assembly".

I've done this and after getting a successfull build, I get the "cannot load assembly" error on the cfg.AddAssembly statement.

I'm guessing almost everyone has dealt with this when switching to VS 2005 but I can't find an in-depth example for the life of me.

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 12, 2006 9:31 am 
Newbie

Joined: Tue Apr 11, 2006 9:59 am
Posts: 3
Here's a little more background on my situation...

I've used NHibernate to develop several smaller apps with ASP.Net 1.1 as well as a couple of enterprise level apps over the past two years and I've become a big fan. Now, like many people, I'm moving to ASP.Net 2.0 with VS 2005 and after doing some research I discovered that VS 2005 doesn't allow users to specify embedded resources. So, my question is what to do with my NHibernate mapping files to make it work in VS 2005?

Currently my file layout is this:

Each object has its own folder with the BLL folder. So if I have a table titled "Certifications", my folder structure would be:

root
--BLL
----Certification
------Certification.cs
------Certification.hbm.xml
------CertificationCollection.cs

In the BLL folder I have a Database.cs file which takes care of the ISession for me and includes the following method:


private static Configuration cfg;
private static ISessionFactory factory;

public static ISession GetSession()
{
if(cfg==null)
{
cfg = new Configuration();
cfg.AddAssembly("EmployeeInfo");
}

if(factory ==null)
factory = cfg.BuildSessionFactory();
return factory.OpenSession();
}


The AddAssembly is where VS 2005 blows up saying it can't load the assembly.

So, should I be placing the classes & mapping files for the objects in a separate project and referencing that assembly in the cfg.AddAssembly statement of this project?

Thanks again.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 12, 2006 2:23 pm 
Newbie

Joined: Fri Mar 24, 2006 3:45 pm
Posts: 18
Best practice is to add a "Class Library" project to your solution and put there your all the content of your BLL folder. Mappings in a class library project CAN be set as embedded resources. Then you can use a web.config file as described in the documentation http://www.hibernate.org/hib_docs/nhibernate/html/quickstart.html#quickstart-intro (just make sure that the <configSections> is the first item after <configuration>). This works fine in VS 2005.

Hector Cruz

If you find my replies helpful, please rate by clicking 'Y' on them. I appreciate it.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 13, 2006 2:13 pm 
Newbie

Joined: Tue Apr 11, 2006 9:59 am
Posts: 3
Excellent! Thank you for the reply Hector. I may have follow-up posts but you've answered my initial question.


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