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.  [ 9 posts ] 
Author Message
 Post subject: NHibernate and WinForms
PostPosted: Fri Apr 04, 2008 5:42 am 
Newbie

Joined: Fri Apr 04, 2008 5:34 am
Posts: 8
I'm new with hibernate and nhibernate...and I don't know if NHibernate can work for a windows form application. For web application you need to configure web.config....but for winform I don't know. Tks!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 04, 2008 1:16 pm 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
It can be used with win forms. For configuration you can use App.config or hibernate.cfg.xml. There're are a few things to care about when you want ti build a win forms app, especially how you do the session handling. Search the forum for that, there're are a few threads covering that topic.

_________________
--Wolfgang


Top
 Profile  
 
 Post subject: Re: NHibernate and WinForms
PostPosted: Tue Apr 08, 2008 6:48 am 
Newbie

Joined: Fri Apr 04, 2008 5:34 am
Posts: 8
For a web application I use a class NHibernateHttpModule which serialize IHttpModule. I don't know what should I use for winforms. pls help...I'm newbie....


Top
 Profile  
 
 Post subject: My configuration file
PostPosted: Wed Apr 09, 2008 8:47 am 
Newbie

Joined: Fri Apr 04, 2008 5:34 am
Posts: 8
I've already made that. But I have a problem with sql driver. I get an exception: Could not create the driver from database NHibernate.Driver.MySqlDataDriver. For web application it works, but for winform not.
This is the configuration file:
<?xml version='1.0' encoding='utf-8'?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">

<!-- an ISessionFactory instance -->
<session-factory>

<!-- properties -->
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="connection.driver_class">NHibernate.Driver.MySqlDataDriver</property>
<property name="connection.connection_string">Server=localhost;initial catalog=nhibernate;DataBase=bank;User Id=root;Password=</property>
<property name="show_sql">false</property>
<property name="dialect">NHibernate.Dialect.MySQLDialect</property>
<property name="use_outer_join">true</property>

</session-factory>

</hibernate-configuration>

Pls...HELP!!!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 09, 2008 8:59 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
Have a look here http://forum.hibernate.org/viewtopic.php?p=2374130. Does that solve your problem ? If not, check if you have an inner exception and post the log.

_________________
--Wolfgang


Top
 Profile  
 
 Post subject: re...
PostPosted: Wed Apr 09, 2008 9:13 am 
Newbie

Joined: Fri Apr 04, 2008 5:34 am
Posts: 8
If I made the configuration in c# like this it works.

Configuration config;
config = new Configuration();
config.SetProperty(NHibernate.Cfg.Environment.ConnectionProvider, "NHibernate.Connection.DriverConnectionProvider");
config.SetProperty(NHibernate.Cfg.Environment.Dialect, "NHibernate.Dialect.MySQLDialect");
config.SetProperty(NHibernate.Cfg.Environment.ConnectionDriver, "NHibernate.Driver.MySqlDataDriver");
config.SetProperty(NHibernate.Cfg.Environment.ConnectionString, "Server=localhost;Database=bank;User ID=root;Password= ");


Top
 Profile  
 
 Post subject: Re
PostPosted: Wed Apr 09, 2008 9:15 am 
Newbie

Joined: Fri Apr 04, 2008 5:34 am
Posts: 8
wolli wrote:
Have a look here http://forum.hibernate.org/viewtopic.php?p=2374130. Does that solve your problem ? If not, check if you have an inner exception and post the log.


I will try it, but I already have MySql.Data.dll in my project. I will try with this...maybe is something modified.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 09, 2008 9:18 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
Since it's working if yo configure it by hand, I suppose the link doesn't help very much. Does your exeption have an inner exception ? Post the log !

_________________
--Wolfgang


Top
 Profile  
 
 Post subject: Resolved
PostPosted: Wed Apr 09, 2008 10:10 am 
Newbie

Joined: Fri Apr 04, 2008 5:34 am
Posts: 8
I've configured the path for configuration file. Is in the same directory, I don't know why he didn't find it before and why it's a txt file and not xml, but now it works. Tks for the solutions.

config.Configure("nhibernate.cfg.xml.txt");


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