Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. The Weird and The Wonderful
  4. Help! NHibernate data saving problem.

Help! NHibernate data saving problem.

Scheduled Pinned Locked Moved The Weird and The Wonderful
helpc++javadatabasesysadmin
14 Posts 8 Posters 20 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Harry Sun

    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;

    S Offline
    S Offline
    StM0n
    wrote on last edited by
    #2

    yeah, i see the horror in this :)

    (yes|no|maybe)*

    1 Reply Last reply
    0
    • H Harry Sun

      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;

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #3

      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.

      My blog | My articles

      J 1 Reply Last reply
      0
      • H Harry Sun

        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;

        J Offline
        J Offline
        Justin Perez
        wrote on last edited by
        #4

        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

        P H 2 Replies Last reply
        0
        • P Pete OHanlon

          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.

          My blog | My articles

          J Offline
          J Offline
          Justin Perez
          wrote on last edited by
          #5

          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

          1 Reply Last reply
          0
          • J Justin Perez

            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

            P Offline
            P Offline
            Pete OHanlon
            wrote on last edited by
            #6

            Nice :laugh:

            Deja View - the feeling that you've seen this post before.

            My blog | My articles

            L 1 Reply Last reply
            0
            • J Justin Perez

              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

              H Offline
              H Offline
              Harry Sun
              wrote on last edited by
              #7

              I took the lesson. Thank you.

              1 Reply Last reply
              0
              • H Harry Sun

                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;

                L Offline
                L Offline
                leppie
                wrote on last edited by
                #8

                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 now

                H 1 Reply Last reply
                0
                • P Pete OHanlon

                  Nice :laugh:

                  Deja View - the feeling that you've seen this post before.

                  My blog | My articles

                  L Offline
                  L Offline
                  Luc Pattyn
                  wrote on last edited by
                  #9

                  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.


                  P 1 Reply Last reply
                  0
                  • L leppie

                    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 now

                    H Offline
                    H Offline
                    Harry Sun
                    wrote on last edited by
                    #10

                    Thanks 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.

                    1 Reply Last reply
                    0
                    • L Luc Pattyn

                      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.


                      P Offline
                      P Offline
                      Pete OHanlon
                      wrote on last edited by
                      #11

                      :laugh:

                      Deja View - the feeling that you've seen this post before.

                      My blog | My articles

                      1 Reply Last reply
                      0
                      • H Harry Sun

                        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;

                        L Offline
                        L Offline
                        Lost User
                        wrote on last edited by
                        #12

                        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

                        D H 2 Replies Last reply
                        0
                        • L Lost User

                          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

                          D Offline
                          D Offline
                          DavidNohejl
                          wrote on last edited by
                          #13

                          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

                          1 Reply Last reply
                          0
                          • L Lost User

                            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

                            H Offline
                            H Offline
                            Harry Sun
                            wrote on last edited by
                            #14

                            Dear Richard, That is what the problem is. I really appreciate to what you did. It has been tough time for me. You saved me. Thank you again. Harry

                            1 Reply Last reply
                            0
                            Reply
                            • Reply as topic
                            Log in to reply
                            • Oldest to Newest
                            • Newest to Oldest
                            • Most Votes


                            • Login

                            • Don't have an account? Register

                            • Login or register to search.
                            • First post
                              Last post
                            0
                            • Categories
                            • Recent
                            • Tags
                            • Popular
                            • World
                            • Users
                            • Groups