GenericADOException: Failed to insert

I am trying to store an order object in a database that is many-to-one related to the pastaIndividual table.

But I get this exception:

Error: NHibernate.Exceptions.GenericADOException: Failed to insert: [FrancosPoS.DBMapping.order] [SQL: INSERT INTO order (price, cash, credit, obs) VALUES (?,?,?,?); SELECT LAST_INSERT_ID ()] ---> MySql.Data.MySqlClient.MySqlException: You have an error in your SQL syntax; check the manual that matches the version of your MySQL server. for the correct syntax to use near order (price, cash, credit, obs) VALUES ('123', 1, 0, 'Nhibernate'); SELECT LAST_ 'on line 1

Here is my order mapping table:

<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping assembly="FrancosPoS" namespace="FrancosPoS.DBMapping" xmlns="urn:nhibernate-mapping-2.2">
  <class name="order" table="order" lazy="true" >
    <id name="idOrder">
      <generator class="identity" />
    </id>
    <set name="pastaIndividual" table="pasta_individual" cascade="save-update">
      <key column="idPastaI"/>
      <one-to-many class="pastaIndividual"/>
    </set>
    <!--<many-to-one insert="false" update="false" lazy="false" name="pastaIndividual" class="FrancosPoS.DBMapping.pastaIndividual">
      <column name="idPastaI" sql-type="int(11)" not-null="false" />
    </many-to-one>-->
    <many-to-one insert="false" update="false" lazy="false" name="pastaCombo" class="FrancosPoS.DBMapping.pastaCombo">
      <column name="idPastaC" sql-type="int(11)" not-null="false" />
    </many-to-one>
    <many-to-one insert="false" update="false" lazy="false" name="pastaFeast" class="FrancosPoS.DBMapping.pastaFeast">
      <column name="idPastaF" sql-type="int(11)" not-null="false" />
    </many-to-one>
    <many-to-one insert="false" update="false" lazy="false" name="salad" class="FrancosPoS.DBMapping.salad">
      <column name="idSalad" sql-type="int(11)" not-null="false" />
    </many-to-one>
    <many-to-one insert="false" update="false" lazy="false" name="drink" class="FrancosPoS.DBMapping.drink">
      <column name="idDrink" sql-type="int(11)" not-null="false" />
    </many-to-one>
    <property name="price">
      <column name="price" sql-type="decimal(8,4)" not-null="true" />
    </property>
    <property name="cash">
      <column name="cash" sql-type="tinyint(1)" not-null="false" />
    </property>
    <property name="credit">
      <column name="credit" sql-type="tinyint(1)" not-null="false" />
    </property>
    <property name="obs">
      <column name="obs" sql-type="varchar(150)" not-null="false" />
    </property>
  </class>
</hibernate-mapping>

Here is my past individual display:

<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping assembly="FrancosPoS" namespace="FrancosPoS.DBMapping" xmlns="urn:nhibernate-mapping-2.2">
  <class name="pastaIndividual" table="pasta_individual" lazy="true" >
    <id name="idPastaI">
      <generator class="identity" />
    </id>
    <property name="type">
      <column name="type" sql-type="varchar(25)" not-null="true" />
    </property>
    <property name="price">
      <column name="price" sql-type="decimal(8,4)" not-null="true" />
    </property>
  </class>
</hibernate-mapping>

, <set> <many-to-one>, .

, - ?

.

+3
1

- . , NHibernate .

 <class name="order" table="`order`" lazy="true" >
+3

All Articles