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: looking for a solution
PostPosted: Mon Oct 12, 2009 2:41 pm 
Newbie

Joined: Mon Oct 12, 2009 1:31 pm
Posts: 2
For some reason an example for nhibernate will not work...keep coming up with this error

Line 21: NHibernate.Cfg.Configuration config = new NHibernate.Cfg.Configuration();
Line 22: // add our assembly
Line 23: config.AddAssembly("ContactDomain");
Line 24: // setup nhibernate session
Line 25: NHibernate.ISessionFactory factory = config.BuildSessionFactory();


Source File: C:\Documents and Settings\bdavis\My Documents\Visual Studio 2008\Projects\ContactDomain\ContactManager\Default.aspx.cs Line: 23

Stack Trace:


[InvalidOperationException: Could not find the dialect in the configuration]
NHibernate.Dialect.Dialect.GetDialect(IDictionary`2 props) +186
NHibernate.Cfg.Configuration.AddValidatedDocument(NamedXmlDocument doc) +163

[MappingException: Could not compile the mapping document: ContactDomain.Contact.hbm.xml]
NHibernate.Cfg.Configuration.LogAndThrow(Exception exception) +109
NHibernate.Cfg.Configuration.AddValidatedDocument(NamedXmlDocument doc) +372
NHibernate.Cfg.Configuration.ProcessMappingsQueue() +51
NHibernate.Cfg.Configuration.AddDocumentThroughQueue(NamedXmlDocument document) +53
NHibernate.Cfg.Configuration.AddXmlReader(XmlReader hbmReader, String name) +72
NHibernate.Cfg.Configuration.AddInputStream(Stream xmlInputStream, String name) +159
NHibernate.Cfg.Configuration.AddResource(String path, Assembly assembly) +268
NHibernate.Cfg.Configuration.AddAssembly(Assembly assembly) +239
NHibernate.Cfg.Configuration.AddAssembly(String assemblyName) +214
ContactManager._Default.btnSaveContact_Click(Object sender, EventArgs e) in C:\Documents and Settings\bdavis\My Documents\Visual Studio 2008\Projects\ContactDomain\ContactManager\Default.aspx.cs:23
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565


<configSections>
<section
name="nhibernate" type="System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
/>
</configSections>

<nhibernate>
<add
key="hibernate.connection.provider"
value="NHibernate.Connection.DriverConnectionProvider"
/>
<add
key="hibernate.dialect"
value="NHibernate.Dialect.MsSql2000Dialect"
/>
<add
key="hibernate.connection.driver_class"
value="NHibernate.Driver.SqlClientDriver"
/>
<add
key="hibernate.connection.connection_string"
value="Data Source=d10401;Initial Catalog=Contacts;Persist Security Info=True;User ID=bdavis;Password=b0ldtwo;"
/>
</nhibernate>


// setup nhibernate configuration
NHibernate.Cfg.Configuration config = new NHibernate.Cfg.Configuration();
// add our assembly
config.AddAssembly("ContactDomain");
// setup nhibernate session
NHibernate.ISessionFactory factory = config.BuildSessionFactory();
NHibernate.ISession session = factory.OpenSession();
// start nhibernate transaction
NHibernate.ITransaction transaction = session.BeginTransaction();

// create contact
Contact contact = new Contact();
contact.FirstName = txtFirstName.Text;
contact.LastName = txtLastName.Text;
contact.Email = txtEmail.Text;
contact.Telephone = txtTelephone.Text;

// Tell NHibernate that this object should be saved
session.Save(contact);

// commit all of the changes to the DB and close the ISession
transaction.Commit();
session.Close();


Top
 Profile  
 
 Post subject: Re: looking for a solution
PostPosted: Tue Oct 13, 2009 12:29 am 
Newbie

Joined: Mon Oct 12, 2009 4:35 am
Posts: 3
Location: Thailand
Hi there,

I had the same problem before, did you add reference to the MySql.Data dll ? Make sure u go into the property of that reference and make copy local = "True". And about your dialect config, im not sure if this is going to solve it, but check out my config and see if u can use it this way:

Code:
<property name="hbm2ddl.keywords">none</property>
    <property name="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle</property>
    <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
    <property name="connection.driver_class">NHibernate.Driver.MySqlDataDriver</property>
    <property name="connection.connection_string">Server=localhost;Database=NGV;User ID=root;Password=root;CharSet=latin1</property>
    [b]<property name="dialect">NHibernate.Dialect.MySQL5Dialect</property>[/b]


Let me know if this works, im new to this too so it might not be the same issue, but I try to help!

Good luck

Vishan S Gill

_________________
Vishan S Gill
Tuple Solutions Co., Ltd.
Web Solution Analyst
Email: vsgill@tuple.co.th / vishan.s.gill@gmail.com


Top
 Profile  
 
 Post subject: Re: looking for a solution
PostPosted: Fri Oct 23, 2009 8:54 am 
Newbie

Joined: Mon Oct 12, 2009 1:31 pm
Posts: 2
Thanks adding the proxy lines in did the trick...the changes must have occured after the book i'm looking at was printed


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.