Hello,
I am using
NHibernate version: 1.2 and i have a problem when closing the session.
I am using MySQL 5.1.16 BETA running @localhost. And the .NET 1.1 MySql Connector
First some infos about the files:
Mapping documents: DLKunde.Kunde.xml
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="DLKunde.Kunde, DLKunde" table="kunden">
<id name="Kid" column="kID" type="int">
<generator class="assigned" />
</id>
<property name="Vorname" column="Vorname" type="String" length="45"/>
<property name="Nachname" column="Nachname" type="String" length="45"/>
<property name="Strasse" column="Strasse" type="String" length="45"/>
<property name="Plz" column="PLZ" type="int"/>
<property name="Umsatz" column="Umsatz" type="int"/>
</class>
</hibernate-mapping>
The properties:
Configuration config = new Configuration();
//config.Configure();
IDictionary props = new Hashtable();
String connectionString = "Server=localhost;Database=ticketline_db;User ID=root;";
props.Add("hibernate.dialect", "NHibernate.Dialect.MySQLDialect");
props.Add("hibernate.connection.provider", "NHibernate.Connection.DriverConnectionProvider");
props.Add("hibernate.connection.driver_class", "NHibernate.Driver.MySqlDataDriver");
props.Add("hibernate.connection.connection_string", connectionString);
config.AddProperties(props);
//config.AddFile("Dummy.hbm.xml");
config.AddFile("DLKunde.Kunde.hbm.xml");
I have had several problems with saving the properties in the hibernate.cfg.xml, thats why i am adding the properties in the source code
Source Code of the session:
ISession session = factory.OpenSession();
ITransaction tx = session.BeginTransaction();
session.Save(k);
tx.Commit();
session.Close(); -> Error Message
ERROR:
An unhandled exception of type 'NHibernate.ADOException' occurred in nhibernate.dll
Additional information: could not insert: [DLKunde.Kunde#99][SQL: INSERT INTO kunden (Vorname, Nachname, Strasse, PLZ, Umsatz, kID) VALUES (?, ?, ?, ?, ?, ?)]
The Object "k" has values, when session.save(k) is executed. Thats why i dont know why the insert command has the "?" values.
thanks for the help,
regards
|