-->
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.  [ 2 posts ] 
Author Message
 Post subject: InvalidCastException in NHibernate Core using mysql 5
PostPosted: Sun Jun 14, 2009 3:43 am 
Newbie

Joined: Sun Jun 14, 2009 2:59 am
Posts: 2
Hello there,

I am trying to use NHibernate with Spring.Net und mySQL 5. However, when setting up the connection and creating the SessionFactoryObject, I get this InvalidCastException:

NHibernate seems to cast MySql.Data.MySqlClient.MySqlConnection to System.Data.Common.DbConnection which causes the exception.

Code:
System.InvalidCastException wurde nicht behandelt.
  Message="Das Objekt des Typs \"MySql.Data.MySqlClient.MySqlConnection\" kann nicht in Typ \"System.Data.Common.DbConnection\" umgewandelt werden."
  Source="NHibernate"
  StackTrace:
       bei NHibernate.Tool.hbm2ddl.SuppliedConnectionProviderConnectionHelper.Prepare() in c:\CSharp\NH\nhibernate\src\NHibernate\Tool\hbm2ddl\SuppliedConnectionProviderConnectionHelper.cs:Zeile 25.
       bei NHibernate.Tool.hbm2ddl.SchemaMetadataUpdater.GetReservedWords(Dialect dialect, IConnectionHelper connectionHelper) in c:\CSharp\NH\nhibernate\src\NHibernate\Tool\hbm2ddl\SchemaMetadataUpdater.cs:Zeile 43.
       bei NHibernate.Tool.hbm2ddl.SchemaMetadataUpdater.Update(ISessionFactory sessionFactory) in c:\CSharp\NH\nhibernate\src\NHibernate\Tool\hbm2ddl\SchemaMetadataUpdater.cs:Zeile 17.
       bei NHibernate.Impl.SessionFactoryImpl..ctor(Configuration cfg, IMapping mapping, Settings settings, EventListeners listeners) in c:\CSharp\NH\nhibernate\src\NHibernate\Impl\SessionFactoryImpl.cs:Zeile 169.
       bei NHibernate.Cfg.Configuration.BuildSessionFactory() in c:\CSharp\NH\nhibernate\src\NHibernate\Cfg\Configuration.cs:Zeile 1090.
       bei OrmTest.Program.Main(String[] args) in C:\Users\Max\Documents\Visual Studio 2008\Projects\OrmTest\OrmTest\Program.cs:Zeile 24.
       bei System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       bei System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       bei Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       bei System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       bei System.Threading.ThreadHelper.ThreadStart()
  InnerException:




I am using the programmatically setup approach in order to get a quick NHibernate Setup. Here is the setup Code:

Code:
            Configuration config = new Configuration();
            Dictionary<string, string> props = new Dictionary<string, string>();
            props.Add("dialect", "NHibernate.Dialect.MySQL5Dialect");
            props.Add("connection.provider", "NHibernate.Connection.DriverConnectionProvider");
            props.Add("connection.driver_class", "NHibernate.Driver.MySqlDataDriver");
            props.Add("connection.connection_string", "Server=localhost;Database=orm_test;User ID=root;Password=password");
            props.Add("proxyfactory.factory_class", "NHibernate.ByteCode.Spring.ProxyFactoryFactory, NHibernate.ByteCode.Spring");
            config.AddProperties(props);
            config.AddFile("Person.hbm.xml");
            ISessionFactory factory = config.BuildSessionFactory();
            ISession session = factory.OpenSession();


Is something missing? I downloaded the current mysql Connector from the mysql Website.


Top
 Profile  
 
 Post subject: Re: InvalidCastException in NHibernate Core using mysql 5
PostPosted: Sun Jun 14, 2009 7:10 am 
Newbie

Joined: Sun Jun 14, 2009 2:59 am
Posts: 2
Shame on me, I downloaded accidently a wrong mysql connector and not the latest version: http://dev.mysql.com/downloads/connector/net/6.0.html

Sorry!


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