Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Mapping documents:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="NHibernate.Examples.QuickStart2.User, QuickStart2" 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>
Code between sessionFactory.openSession() and session.close():
Configuration cfg = new Configuration();
try
{
cfg.AddXmlFile(@"C:\SSWF\RequirementsContentManagement\Test\QuickStart2\QuickStart2\User.hbm.xml");
}
catch (Exception ex)
{
}
ISessionFactory factory = cfg.BuildSessionFactory();
ISession session = factory.OpenSession();
ITransaction transaction = session.BeginTransaction();
User newUser = new User();
newUser.Id = "Joe_cool";
newUser.Username = "Joseph Cool";
newUser.Password = "secret";
newUser.EmailAdresses = "joe@joe.com";
newUser.LastLogon = DateTime.Now;
session.Save(newUser);
transaction.Commit();
session.Close();
Full stack trace of any exception that occurs:
NHibernate.HibernateException was unhandled
Message="The hibernate.connection.driver_class must be specified in the NHibernate configuration section."
Source="NHibernate"
StackTrace:
at NHibernate.Connection.ConnectionProvider.ConfigureDriver(IDictionary settings)
at NHibernate.Connection.UserSuppliedConnectionProvider.Configure(IDictionary settings)
at NHibernate.Connection.ConnectionProviderFactory.NewConnectionProvider(IDictionary settings)
at NHibernate.Cfg.SettingsFactory.BuildSettings(IDictionary properties)
at NHibernate.Cfg.Configuration.BuildSettings()
at NHibernate.Cfg.Configuration.BuildSessionFactory()
at NHibernate.Examples.QuickStart2.queryObjects.query() in C:\SSWF\RequirementsContentManagement\Test\QuickStart2\QuickStart2\queryObjects.cs:line 22
at NHibernate.Examples.QuickStart2.Form1.button1_Click(Object sender, EventArgs e) in C:\SSWF\RequirementsContentManagement\Test\QuickStart2\QuickStart2\Form1.cs:line 21
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at NHibernate.Examples.QuickStart2.Program.Main() in C:\SSWF\RequirementsContentManagement\Test\QuickStart2\QuickStart2\Program.cs:line 17
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
Name and version of the database you are using:
MSSQL 2000
Problems with Session and transaction handling?
Read this:
http://hibernate.org/42.html
Hi,
I am following this tutorial:
http://www.hibernate.org/362.html
But I get an error when I try to create the ISessionFactory. It complains about the hibernate.connection.driver_class is not specified in the NHibernate configuration section. I have created the config file and named it app.config. Do I need to do anything else to explain .net that it is my config file?