wolli wrote:
In that case something with your hibernate configuration is wrong. Can you post your config file and the code where you build the session factory ?
Hi,
My Class file is, static void Main()
{
CreateEmployeeAndSaveToDatabase();
Console.WriteLine("Press any key to exit...");
}
static void CreateEmployeeAndSaveToDatabase()
{
HelloWorldNHibernate.Employee tobin = new HelloWorldNHibernate.Employee();
tobin.name = "Tobin Harris";
using (ISession session = OpenSession())
{
using (ITransaction transaction = session.BeginTransaction())
{
session.Save(tobin);
transaction.Commit();
}
Console.WriteLine("Saved Tobin to the database");
}
}
static ISession OpenSession()
{
Configuration c = new Configuration();
c.AddAssembly(Assembly.GetCallingAssembly());
ISessionFactory f = c.BuildSessionFactory();
return f.OpenSession();
}
and my xml Config file : <?xml version="1.0"?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" auto-import="true">
<class name="HelloWorldNHibernate.Employee, HelloWorldNHibernate" lazy="false">
<id name="id" access="field">
<generator class="native" />
</id>
<property name="name" access="field" column="name"/>
<many-to-one access="field" name="manager" column="manager" cascade="all"/>
</class>
</hibernate-mapping>
And App.config File :
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="nhibernate" type="System.Configuration.NameValueSectionHandler, System,
Version=1.0.3300.0,Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</configSections>
<nhibernate>
<add key="hibernate.show_sql"
value="false" />
<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=DTDB;Initial Catalog=PPO_DEV;Integrated Security=SSPI;" />
</nhibernate>
</configuration>
Thanks for your Response..