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: Nhibernate 2.1problem? Could not find the dialect
PostPosted: Thu Apr 09, 2009 8:37 am 
Newbie

Joined: Mon Mar 30, 2009 2:47 pm
Posts: 15
hi! people.I came accross the nhibernate library and wanted to give a try after succefully completed the great article from nhforge http://nhforge.org/wikis/howtonh/your-first-nhibernate-based-application.aspx
i decided to give for my own a try on a real project with the version 2.1.0 irecently downloaded and with which i completed the tutorial.
after being through a lot of hussle i still can get up on my own running for three days now.i use even mygeneration to generate the mappings and classes for me.I know this post is long but i want to give all the details to help you help me ;)
so there are couples of tables in the database.on my test
Code:
private ISessionFactory _sessionFactory;
        private readonly Configuration cfg = new Configuration();

        [TestFixtureSetUp]
        public void testfisturesetup()
        {
            cfg.Configure().AddAssembly(typeof(Currency).Assembly);
            _sessionFactory = cfg.BuildSessionFactory();

        }
       

        [Test]
        public void can_add_currency()
        {
            Currency c = new Currency();
            c.Authorizer = "John";
            c.Name = "Euro";
            c.Comments ="No Comments";
            c.Add(c);

            using (ISession session = _sessionFactory.OpenSession())
            {
                Currency fromdb = session.Get<Currency>(c.CurrencyId);
                Assert.IsNotNull(fromdb);
                Assert.AreEqual(c.Name,fromdb.Name);
                Assert.AreNotSame(c,fromdb);
                Assert.AreEqual(c.Authorizer,fromdb.Authorizer);
                Assert.AreEqual(c.Comments, fromdb.Comments);
            }
        }

i only target the class Currency mapping to the table currency (currency_id(identity)|name|authorizer|date_created(getdate())|comment)
Quote:
there is one hibernate.cfg.xml in the projects itself and one in the test project

and it's looking like
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
  <session-factory>
    <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
    <property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
    <property name="connection.connection_string">Data Source=.;Initial Catalog=vouchman;Integrated Security=True</property>
    <property name="dialect">NHibernate.Dialect.MsSql2005Dialect</property>
    <property name="proxyfactory.factory_class">NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu</property>
  </session-factory>
</hibernate-configuration>


Quote:
the test failure for gives this reason:"Could not compile the mapping document Voucher.hbm.xml"
and on detail view i can read System.InvalidOperationException : Could not find the dialect in the configuration


Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="vprovider" namespace="vprovider">
   <class name="vprovider.Voucher" table="voucher">

      <id name="VoucherId" column="voucher_id" type="Guid">
         <generator class="guid.comb"/>
      </id>
      <property column="PIN" type="binary" name="Pin" not-null="true" />
      <many-to-one name="BatchNo" column="batch_no" class="Batch" />
      <property column="serial_no" type="Int32" name="SerialNo" not-null="true" />
      <property column="date_created" type="DateTime" name="DateCreated" not-null="true" />
      
   </class>
</hibernate-mapping>

What can be the things i'm obviously doing wrong?Please.Thanks for reading
Quote:
P.S: the type binary is mapped to the property of the type byte[] in the mapping class


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 09, 2009 10:57 am 
Newbie

Joined: Mon Mar 30, 2009 2:47 pm
Posts: 15
People!
i'm just wondering if there something stupid about my posts or if i'm only asking help about stupid stuffs.Honest this my second post and none of them was replied.No to say that people are obliged to reply.But this is not my first forum experience. i'm a member of devnetwork, linuxquestions, fedoraforum and even codeproject.there are nice people out there ,even there when you post stupid questions they'll tell you something or to go and search on google or something.Well i spent the whole of yesterday on google and on the " read this first" and so far nothing updated documentations are hard to find.So i came here the "community of the great hibernate " and yet i'm still at the same place, plus i'm properly ignored.It's amazing!!Thanks anyway


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 09, 2009 12:17 pm 
Regular
Regular

Joined: Wed Feb 11, 2009 10:58 am
Posts: 55
uhm... your post is here 2 1/2 Hours and you flame arround cause nobody wants to help? That is not nice for a newbie.

Did you set the "copy to output directory" to always for the nhibernate.cfg.xml file? Because this file must not be a embedded resource, but has to be copied to the output directory.
And btw don't forget to add a reference to the LinFu Proxy library to your project.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 09, 2009 1:21 pm 
Newbie

Joined: Mon Mar 30, 2009 2:47 pm
Posts: 15
sorry about that.It's just frustrating being stacked somewhere for 2 days for so little.Maybe it's just this the second post .Anyway! sorry again.Yes i did build action: embedded resource for the mapping file and copy to output:always copy for the cfg.xml file.that's from the tutorial.thanks for the reply really appreciate it


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 09, 2009 2:30 pm 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
Enable Debug logging with log4net and check the output. There should be information about the used configuration and if the mapping files are processed.

_________________
--Wolfgang


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 14, 2009 2:48 pm 
Newbie

Joined: Mon Mar 30, 2009 2:47 pm
Posts: 15
I deleted the whole stuff and restarted from scratch based on the tutorial.so this time instead of putting all the classes and their mapping files i just put one that works for now.I've planned to add the other classes progressively.That itself made me think about how to work with multiple classes.i thought i could add multiple .AddClass() but i've read billy McCafferty architecture articles at http://www.codeproject.com/KB/architecture/NHibernateBestPractices.aspx
but honesty i didn't understand much.I need just to works multiple classes with my session that has to be thread safe.Is there any simple way to achieve that?


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.