-->
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.  [ 6 posts ] 
Author Message
 Post subject: Following the quick start tutorial is not a good idea
PostPosted: Mon May 29, 2006 5:47 am 
Newbie

Joined: Mon May 29, 2006 5:19 am
Posts: 4
NHibernate version:1.2.0

Develop tools:VS 2005

Name and version of the database you are using:MS SQL 2K

following the quick start tutorial

Hi! I'm a newbie on NHibernate, and I'm facing a basic trouble when trying to execute the Quick Start Guide (http://www.hibernate.org/362.html):

I have followed the tutorial line by line, but in the following code line an error is occurring:

Code:
private void cmdOK_Click(object sender, System.EventArgs e)
      {
         Configuration cfg = new Configuration();
         cfg.AddAssembly("NHibernate.Examples.QuickStart");

         ISessionFactory factory = cfg.BuildSessionFactory();
         ISession session = factory.OpenSession();
         ITransaction transaction = session.BeginTransaction();


and I got error, but I had follow other topic and fix

Code:
cfg.AddAssembly("NHibernate.Examples.QuickStart");
To

cfg.AddAssembly(My Assembly Name);

ok,pass,but.....I get a new error at the next line
Code:
ISessionFactory factory = cfg.BuildSessionFactory();


The error message is :Could not instantiate connection provider: /NHibernate.Connection.DriverConnectionProvider

Oh! come on my god .... I'm a loser,Who can help me?
[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 29, 2006 6:07 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Quote:
Could not instantiate connection provider: /NHibernate.Connection.DriverConnectionProvider


The slash (/) should not be there.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 29, 2006 8:59 pm 
Newbie

Joined: Mon May 29, 2006 5:19 am
Posts: 4
?what?
That's error message , What should I do?


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 30, 2006 3:20 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Sorry, check your Web.config, the connection provider configuration should look like this:
Code:
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>


Check carefully that you don't have that slash before the class name.


Top
 Profile  
 
 Post subject: further help
PostPosted: Wed May 31, 2006 6:14 am 
Newbie

Joined: Fri May 05, 2006 11:33 am
Posts: 6
Location: London
Hi Guys,

I've also been going through the quickstart and have encountered similar problems, mainly around AddAssembly(). In the quickstart guide, there's basically only one project with the User.cs and the User.hbm.xml in the project (not as references).

I've created a project called TestNHibernate. My User.hbm.xml file is :

Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
    <class name="NHibernate.Examples.QuickStart.User, TestNHibernate" table="users">
   <id name="Id" column="LogonId" type="String" length="20">
      <generator class="assigned" />
   </id>
   
   <property name="UserName" column="Name" type="String" length="40"/>
   <property name="Password" type="String" length="20"/>
   <property name="EmailAddress" type="String" length="40"/>
   <property name="LastLogon" type="DateTime"/>
</class>
</hibernate-mapping>


the user.cs is defined in the namespace (NHibernate.Examples.QuickStart). Now, in the code, if i do the line
Code:
cfg.AddAssembly("TestNHibernate"); 
(as directed by the quickstart guide), I get NHibernate.MappingExceptionL Unknown entity class: NHibernate.Examples.Quickstart.User.
However, if I replace this line with :
Code:
cfg.AddXmlFile(@"C:\Documents and Settings\waat\My Documents\Visual Studio Projects\TestNHibernate\User.hbm.xml");

It works fine.

I've read through a few of the other posts, I'm guessing that to use AddAssembly, I need to include the dll in my references. however as i'm currently in that project already, doesn't this make a circular reference back to itself? Am I missing something?

Thanks in advance


Top
 Profile  
 
 Post subject: solved it!
PostPosted: Wed May 31, 2006 6:34 am 
Newbie

Joined: Fri May 05, 2006 11:33 am
Posts: 6
Location: London
Hi Guys,

ok not to worry, i've figured it out. All you have to do is set the Build Action of the file to "Embedded Resource". My mistake as i did not see the big NOTE in the quick reference guide that says :

NOTE: If you are using Visual Studio .NET to compile make sure that you set the Build Action of the User.hbm.xml file to Embedded Resource. The mapping file will now be a part of the Asssembly. The subtle detail's importance will be evident later.

Toast


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