Help! NHibernate data saving problem.
-
Hi, I am in the trouber of the error while the project trys to saving the data to child table. The error message is shown below: NHibernate.ADOException: could not insert: [ConsoleApplication1.user][SQL: INSERT INTO user (UNAME, NID) VALUES (?, ?)] ---> So confused that why it cannot get values to save. NHibernate I used is version 1.2. The code files are list below, please help me out here. Thanks in advance. app.config: <?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <section name="nhibernate" type="System.Configuration.NameValueSectionHandler, System, Version=1.2.0.4000,Culture=neutral, PublicKeyToken=b77a5c561934e089"/> </configSections> <nhibernate> <add key="hibernate.connection.provider" value="NHibernate.Connection.DriverConnectionProvider"/> <add key="hibernate.dialect" value="NHibernate.Dialect.MsSql2005Dialect"/> <add key="hibernate.connection.driver_class" value="NHibernate.Driver.SqlClientDriver"/> <add key="hibernate.connection.connection_string" value="Server=;initial catalog=;Persist Security Info=True;User ID=;Password="/> </nhibernate> </configuration> user.hbm.xml: <hibernate-mapping default-cascade="none" xmlns="urn:nhibernate-mapping-2.2"> <class name="ConsoleApplication1.user, ConsoleApplication1" table="user"> <id name="UID" type="System.Int32" column="UID" unsaved-value="0"> <generator class="native" /> </id> <property name="UNAME" type="System.String" column="UNAME" not-null="false" /> <many-to-one name="Nationality" class="ConsoleApplication1.nationality, ConsoleApplication1" fetch="select" cascade="all"> <column name="NID" not-null="false" /> </many-to-one> </class> </hibernate-mapping> user.hbm.cs: namespace ConsoleApplication1 { [System.SerializableAttribute()] public class Abstractuser { private int uID; private string uNAME; private ConsoleApplication1.nationality nationality; public virtual int UID { get { return this.uID; } set { this.uID = value; } } public virtual string UNAME { get { return this.uNAME; } set { this.uNAME = value;
-
Hi, I am in the trouber of the error while the project trys to saving the data to child table. The error message is shown below: NHibernate.ADOException: could not insert: [ConsoleApplication1.user][SQL: INSERT INTO user (UNAME, NID) VALUES (?, ?)] ---> So confused that why it cannot get values to save. NHibernate I used is version 1.2. The code files are list below, please help me out here. Thanks in advance. app.config: <?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <section name="nhibernate" type="System.Configuration.NameValueSectionHandler, System, Version=1.2.0.4000,Culture=neutral, PublicKeyToken=b77a5c561934e089"/> </configSections> <nhibernate> <add key="hibernate.connection.provider" value="NHibernate.Connection.DriverConnectionProvider"/> <add key="hibernate.dialect" value="NHibernate.Dialect.MsSql2005Dialect"/> <add key="hibernate.connection.driver_class" value="NHibernate.Driver.SqlClientDriver"/> <add key="hibernate.connection.connection_string" value="Server=;initial catalog=;Persist Security Info=True;User ID=;Password="/> </nhibernate> </configuration> user.hbm.xml: <hibernate-mapping default-cascade="none" xmlns="urn:nhibernate-mapping-2.2"> <class name="ConsoleApplication1.user, ConsoleApplication1" table="user"> <id name="UID" type="System.Int32" column="UID" unsaved-value="0"> <generator class="native" /> </id> <property name="UNAME" type="System.String" column="UNAME" not-null="false" /> <many-to-one name="Nationality" class="ConsoleApplication1.nationality, ConsoleApplication1" fetch="select" cascade="all"> <column name="NID" not-null="false" /> </many-to-one> </class> </hibernate-mapping> user.hbm.cs: namespace ConsoleApplication1 { [System.SerializableAttribute()] public class Abstractuser { private int uID; private string uNAME; private ConsoleApplication1.nationality nationality; public virtual int UID { get { return this.uID; } set { this.uID = value; } } public virtual string UNAME { get { return this.uNAME; } set { this.uNAME = value;
-
Hi, I am in the trouber of the error while the project trys to saving the data to child table. The error message is shown below: NHibernate.ADOException: could not insert: [ConsoleApplication1.user][SQL: INSERT INTO user (UNAME, NID) VALUES (?, ?)] ---> So confused that why it cannot get values to save. NHibernate I used is version 1.2. The code files are list below, please help me out here. Thanks in advance. app.config: <?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <section name="nhibernate" type="System.Configuration.NameValueSectionHandler, System, Version=1.2.0.4000,Culture=neutral, PublicKeyToken=b77a5c561934e089"/> </configSections> <nhibernate> <add key="hibernate.connection.provider" value="NHibernate.Connection.DriverConnectionProvider"/> <add key="hibernate.dialect" value="NHibernate.Dialect.MsSql2005Dialect"/> <add key="hibernate.connection.driver_class" value="NHibernate.Driver.SqlClientDriver"/> <add key="hibernate.connection.connection_string" value="Server=;initial catalog=;Persist Security Info=True;User ID=;Password="/> </nhibernate> </configuration> user.hbm.xml: <hibernate-mapping default-cascade="none" xmlns="urn:nhibernate-mapping-2.2"> <class name="ConsoleApplication1.user, ConsoleApplication1" table="user"> <id name="UID" type="System.Int32" column="UID" unsaved-value="0"> <generator class="native" /> </id> <property name="UNAME" type="System.String" column="UNAME" not-null="false" /> <many-to-one name="Nationality" class="ConsoleApplication1.nationality, ConsoleApplication1" fetch="select" cascade="all"> <column name="NID" not-null="false" /> </many-to-one> </class> </hibernate-mapping> user.hbm.cs: namespace ConsoleApplication1 { [System.SerializableAttribute()] public class Abstractuser { private int uID; private string uNAME; private ConsoleApplication1.nationality nationality; public virtual int UID { get { return this.uID; } set { this.uID = value; } } public virtual string UNAME { get { return this.uNAME; } set { this.uNAME = value;
Harry Sun wrote:
Hi, I am in the trouber of the error while the project trys to saving the data to child table. The error message is shown below:
You've hit the "Y Who Cares" Bug. It's much less advertised than the Y2K bug was, but much more prevalent. Can you feel the apathy? Can you?
Deja View - the feeling that you've seen this post before.
-
Hi, I am in the trouber of the error while the project trys to saving the data to child table. The error message is shown below: NHibernate.ADOException: could not insert: [ConsoleApplication1.user][SQL: INSERT INTO user (UNAME, NID) VALUES (?, ?)] ---> So confused that why it cannot get values to save. NHibernate I used is version 1.2. The code files are list below, please help me out here. Thanks in advance. app.config: <?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <section name="nhibernate" type="System.Configuration.NameValueSectionHandler, System, Version=1.2.0.4000,Culture=neutral, PublicKeyToken=b77a5c561934e089"/> </configSections> <nhibernate> <add key="hibernate.connection.provider" value="NHibernate.Connection.DriverConnectionProvider"/> <add key="hibernate.dialect" value="NHibernate.Dialect.MsSql2005Dialect"/> <add key="hibernate.connection.driver_class" value="NHibernate.Driver.SqlClientDriver"/> <add key="hibernate.connection.connection_string" value="Server=;initial catalog=;Persist Security Info=True;User ID=;Password="/> </nhibernate> </configuration> user.hbm.xml: <hibernate-mapping default-cascade="none" xmlns="urn:nhibernate-mapping-2.2"> <class name="ConsoleApplication1.user, ConsoleApplication1" table="user"> <id name="UID" type="System.Int32" column="UID" unsaved-value="0"> <generator class="native" /> </id> <property name="UNAME" type="System.String" column="UNAME" not-null="false" /> <many-to-one name="Nationality" class="ConsoleApplication1.nationality, ConsoleApplication1" fetch="select" cascade="all"> <column name="NID" not-null="false" /> </many-to-one> </class> </hibernate-mapping> user.hbm.cs: namespace ConsoleApplication1 { [System.SerializableAttribute()] public class Abstractuser { private int uID; private string uNAME; private ConsoleApplication1.nationality nationality; public virtual int UID { get { return this.uID; } set { this.uID = value; } } public virtual string UNAME { get { return this.uNAME; } set { this.uNAME = value;
First, you post the same question 3 times, and in different fourms as well. Well call that second, the cross-posting that is. Third, you don't know how to use a debugger. Fourth, you put 'help!' in your subject. Everyone that posts a question needs help, jackass. Fifth, you can't read the forum rules. This isn't for questions. It's for coding horrors, which yours is, but in a different context. So basically, that makes you a 5x idiot. Quit crop-dusting our forums with your crap question. No one cares. Had you been civilized about it, you may have gotten some help. As a matter of fact, someone did answer you. They now wish they didn't, and I'm sure they wouldn't have if they'd seen your blatant disregard for the rules. Most people won't. Oh man I wish my device was ready.
I'm going to become rich when I create a device that allows me to punch people in the face over the internet. "If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer
-
Harry Sun wrote:
Hi, I am in the trouber of the error while the project trys to saving the data to child table. The error message is shown below:
You've hit the "Y Who Cares" Bug. It's much less advertised than the Y2K bug was, but much more prevalent. Can you feel the apathy? Can you?
Deja View - the feeling that you've seen this post before.
Pete O'Hanlon wrote:
You've hit the "Y Who Cares" Bug.
Hopefully said bug causes his system to overload, and a rm -rf /his/job/ must be preformed.
I'm going to become rich when I create a device that allows me to punch people in the face over the internet. "If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer
-
First, you post the same question 3 times, and in different fourms as well. Well call that second, the cross-posting that is. Third, you don't know how to use a debugger. Fourth, you put 'help!' in your subject. Everyone that posts a question needs help, jackass. Fifth, you can't read the forum rules. This isn't for questions. It's for coding horrors, which yours is, but in a different context. So basically, that makes you a 5x idiot. Quit crop-dusting our forums with your crap question. No one cares. Had you been civilized about it, you may have gotten some help. As a matter of fact, someone did answer you. They now wish they didn't, and I'm sure they wouldn't have if they'd seen your blatant disregard for the rules. Most people won't. Oh man I wish my device was ready.
I'm going to become rich when I create a device that allows me to punch people in the face over the internet. "If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer
-
First, you post the same question 3 times, and in different fourms as well. Well call that second, the cross-posting that is. Third, you don't know how to use a debugger. Fourth, you put 'help!' in your subject. Everyone that posts a question needs help, jackass. Fifth, you can't read the forum rules. This isn't for questions. It's for coding horrors, which yours is, but in a different context. So basically, that makes you a 5x idiot. Quit crop-dusting our forums with your crap question. No one cares. Had you been civilized about it, you may have gotten some help. As a matter of fact, someone did answer you. They now wish they didn't, and I'm sure they wouldn't have if they'd seen your blatant disregard for the rules. Most people won't. Oh man I wish my device was ready.
I'm going to become rich when I create a device that allows me to punch people in the face over the internet. "If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer
-
Hi, I am in the trouber of the error while the project trys to saving the data to child table. The error message is shown below: NHibernate.ADOException: could not insert: [ConsoleApplication1.user][SQL: INSERT INTO user (UNAME, NID) VALUES (?, ?)] ---> So confused that why it cannot get values to save. NHibernate I used is version 1.2. The code files are list below, please help me out here. Thanks in advance. app.config: <?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <section name="nhibernate" type="System.Configuration.NameValueSectionHandler, System, Version=1.2.0.4000,Culture=neutral, PublicKeyToken=b77a5c561934e089"/> </configSections> <nhibernate> <add key="hibernate.connection.provider" value="NHibernate.Connection.DriverConnectionProvider"/> <add key="hibernate.dialect" value="NHibernate.Dialect.MsSql2005Dialect"/> <add key="hibernate.connection.driver_class" value="NHibernate.Driver.SqlClientDriver"/> <add key="hibernate.connection.connection_string" value="Server=;initial catalog=;Persist Security Info=True;User ID=;Password="/> </nhibernate> </configuration> user.hbm.xml: <hibernate-mapping default-cascade="none" xmlns="urn:nhibernate-mapping-2.2"> <class name="ConsoleApplication1.user, ConsoleApplication1" table="user"> <id name="UID" type="System.Int32" column="UID" unsaved-value="0"> <generator class="native" /> </id> <property name="UNAME" type="System.String" column="UNAME" not-null="false" /> <many-to-one name="Nationality" class="ConsoleApplication1.nationality, ConsoleApplication1" fetch="select" cascade="all"> <column name="NID" not-null="false" /> </many-to-one> </class> </hibernate-mapping> user.hbm.cs: namespace ConsoleApplication1 { [System.SerializableAttribute()] public class Abstractuser { private int uID; private string uNAME; private ConsoleApplication1.nationality nationality; public virtual int UID { get { return this.uID; } set { this.uID = value; } } public virtual string UNAME { get { return this.uNAME; } set { this.uNAME = value;
-
the dog and His Masters Voice. :-D
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips: - before you ask a question here, search CodeProject, then Google; - the quality and detail of your question reflects on the effectiveness of the help you are likely to get; - use PRE tags to preserve formatting when showing multi-line code snippets.
-
I feel nice today, so I will help you once here, thats it though, next time, try the correct forum.
Harry Sun wrote:
unsaved-value="0"
That seems like bogus.
xacc.ide - now with IronScheme support
IronScheme - 1.0 alpha 1 out nowThanks for your kind. I removed that code you mentioned, but the problem still exists. In fact, I thought it is fine for define unsaved-value="0", because I have already make this attribute as incremental identiy in database. While debugging the code, the object which I intend to save in session.save(u) does have correct values. And it works fine if I just work with one table. Am I right? Please tell me if you got time.
-
the dog and His Masters Voice. :-D
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips: - before you ask a question here, search CodeProject, then Google; - the quality and detail of your question reflects on the effectiveness of the help you are likely to get; - use PRE tags to preserve formatting when showing multi-line code snippets.
-
Hi, I am in the trouber of the error while the project trys to saving the data to child table. The error message is shown below: NHibernate.ADOException: could not insert: [ConsoleApplication1.user][SQL: INSERT INTO user (UNAME, NID) VALUES (?, ?)] ---> So confused that why it cannot get values to save. NHibernate I used is version 1.2. The code files are list below, please help me out here. Thanks in advance. app.config: <?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <section name="nhibernate" type="System.Configuration.NameValueSectionHandler, System, Version=1.2.0.4000,Culture=neutral, PublicKeyToken=b77a5c561934e089"/> </configSections> <nhibernate> <add key="hibernate.connection.provider" value="NHibernate.Connection.DriverConnectionProvider"/> <add key="hibernate.dialect" value="NHibernate.Dialect.MsSql2005Dialect"/> <add key="hibernate.connection.driver_class" value="NHibernate.Driver.SqlClientDriver"/> <add key="hibernate.connection.connection_string" value="Server=;initial catalog=;Persist Security Info=True;User ID=;Password="/> </nhibernate> </configuration> user.hbm.xml: <hibernate-mapping default-cascade="none" xmlns="urn:nhibernate-mapping-2.2"> <class name="ConsoleApplication1.user, ConsoleApplication1" table="user"> <id name="UID" type="System.Int32" column="UID" unsaved-value="0"> <generator class="native" /> </id> <property name="UNAME" type="System.String" column="UNAME" not-null="false" /> <many-to-one name="Nationality" class="ConsoleApplication1.nationality, ConsoleApplication1" fetch="select" cascade="all"> <column name="NID" not-null="false" /> </many-to-one> </class> </hibernate-mapping> user.hbm.cs: namespace ConsoleApplication1 { [System.SerializableAttribute()] public class Abstractuser { private int uID; private string uNAME; private ConsoleApplication1.nationality nationality; public virtual int UID { get { return this.uID; } set { this.uID = value; } } public virtual string UNAME { get { return this.uNAME; } set { this.uNAME = value;
You can't use user as a table name and have it work with NHibernate unless you do some special stuff in your mapping file... In your user.hbm.xml do this: //note the square brackets around the table name. That'll fix your problem... Richard http://www.BellaDev.net
-
You can't use user as a table name and have it work with NHibernate unless you do some special stuff in your mapping file... In your user.hbm.xml do this: //note the square brackets around the table name. That'll fix your problem... Richard http://www.BellaDev.net
Please check "Ignore HTML tags in this message" or do something about that <class..., it's not showing up :)
[My Blog]
"Visual studio desperately needs some performance improvements. It is sometimes almost as slow as eclipse." - RĂ¼diger Klaehn
"Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe -
You can't use user as a table name and have it work with NHibernate unless you do some special stuff in your mapping file... In your user.hbm.xml do this: //note the square brackets around the table name. That'll fix your problem... Richard http://www.BellaDev.net