-->
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.  [ 1 post ] 
Author Message
 Post subject: Problem with INSERT command at session.close();
PostPosted: Wed Mar 28, 2007 8:36 am 
Newbie

Joined: Wed Mar 28, 2007 8:18 am
Posts: 1
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.