title: ERROR: You have an error in your SQL syntax in Hibernate
body: <p>I'm having a problem with a record deletion from data base. I've been trying to figure out what i'm doing wrong for couple of hours now. I searched some topics here but none of them answered what am i doing wrong. I've made these 3 tables in my data base:</p>
  
  <pre><code>CREATE TABLE IF NOT EXISTS `dat1`.`M_CUSTOMER_LIST` (
    `CUSTOMER_LIST_ID` int(4) NOT NULL primary KEY AUTO_INCREMENT,
    `C_NAME` varchar(45) NOT NULL,
    `C_LAST_NAME` varchar(45) NOT NULL,
    `C_P_CODE` varchar(12) NOT NULL,
    `C_MAIL` varchar(45) NOT NULL,
    `C_PHONE_NR` varchar(12) NOT NULL,
    `C_USER_TYPE` varchar(45) NOT NULL,
    `C_PASSWORD` varchar(45) NOT NULL
  );
  
  CREATE TABLE IF NOT EXISTS `dat1`.`M_SERVICES` (
   `M_SERVICE_ID` int(4) NOT NULL primary KEY AUTO_INCREMENT,
   `SERVICE_NAME` varchar(45) NOT NULL,
   `SERVICE_PRICE` INT(4) NOT NULL,
   `SERVICE_DESCRIPTION` int(60) NOT NULL
  );
  
  CREATE TABLE IF NOT EXISTS `dat1`.`ORDER` (
    `ORDER_ID` int(4) NOT NULL primary KEY AUTO_INCREMENT,
    `ORDER_DATE` varchar(45) NOT NULL,
    `M_CUST` int(4) NOT NULL,
    `M_SERV` int(4) NOT NULL,
    foreign key (`M_SERV`) references `M_SERVICES`(`M_SERVICE_ID`),
    foreign key (`M_CUST`) references `M_CUSTOMER_LIST`(`CUSTOMER_LIST_ID`)
  );
  </code></pre>
  
  <p>This is my hibernate mapping file:</p>
  
  <pre><code> &lt;?xml version="1.0" encoding="UTF-8"?&gt;
   &lt;!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"&gt;
   &lt;hibernate-mapping&gt;
     &lt;class name="dat3.MCustomerList" table="m_customer_list"&gt;
       &lt;id column="CUSTOMER_LIST_ID" name="customerList_id" type="int"&gt;
         &lt;generator class="native"/&gt;
       &lt;/id&gt;
      &lt;property column="C_NAME" name="c_name" type="string"/&gt;
      &lt;property column="C_L_NAME" name="c_l_name" type="string"/&gt;
      &lt;property column="C_P_CODE" name="c_p_code" type="string"/&gt;
      &lt;property column="C_EMAIL" name="c_email" type="string"/&gt;
      &lt;property column="C_PHONE_NR" name="c_phone_nr" type="string"/&gt;
      &lt;property column="C_USER_TYPE" name="c_user_type" type="string"/&gt;
      &lt;property column="C_PASSWORD" name="c_password" type="string"/&gt;
    &lt;/class&gt;
    &lt;class name="dat3.M_Services" table="m_services"&gt;
      &lt;id column="M_SERVICE_ID" name="m_service_id" type="int"&gt;
    &lt;generator class="native"/&gt;
      &lt;/id&gt;
      &lt;property column="SERVICE_NAME" name="service_name" type="string"/&gt;
      &lt;property column="SERVICE_PRICE" name="service_price" type="int"/&gt;
      &lt;property column="SERVICE_DESCRIPTION" name="service_description" type="string"/&gt;
    &lt;/class&gt;
    &lt;class name="dat3.Order" table="order"&gt;
      &lt;id column="ORDER_ID" name="order_id" type="int"&gt;
    &lt;generator class="native"/&gt;
      &lt;/id&gt;
      &lt;property column="ORDER_DATE" name="order_date" type="date"/&gt;
      &lt;many-to-one class="dat3.MCustomerList" column="M_CUST" name="customerList" not-null="true"/&gt;
      &lt;many-to-one class="dat3.M_Services" column="M_SERV" name="m_service" not-null="true"/&gt;
     &lt;/class&gt;
  &lt;/hibernate-mapping&gt;
  </code></pre>
  
  <p>So when i try to delete one record from my jTable, it gives me an error. Here's the code which i'm using to delete data from jTable and data base:</p>
  
  <pre><code>    if ((this.jTable1.getSelectedRow() != -1) &amp;&amp; (this.jTable1.getValueAt(this.jTable1.getSelectedRow(), 0) != ""))
      {
          ServiceCheck serviceCheck = new ServiceCheck();
          serviceCheck.deleteOrder(Integer.valueOf(this.jTable1.getModel().getValueAt(this.jTable1.getSelectedRow(), 0).toString()).intValue());
      }
      else
      {
        JOptionPane.showMessageDialog(null, "Error");
      }
  </code></pre>
  
  <p>ServiceCheck.java</p>
  
  <pre><code>public void deleteOrder(int id){
    Session session = factory.openSession();
    Transaction tx = null;
    try{
       tx = session.beginTransaction();
       Order order = (Order)session.get(Order.class, Integer.valueOf(id)); 
       session.delete(order); 
       JOptionPane.showMessageDialog(null, "You have successfully deleted your order");
       tx.commit();
    }catch (HibernateException e) {
       if (tx!=null) tx.rollback();
       e.printStackTrace(); 
    }finally {
       session.close(); 
    }
  }
  </code></pre>
  
  <p>Here's the error:</p>
  
  <pre><code> ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order order0_ where order0_.ORDER_ID=2' at line 1
  </code></pre>
  
  <p>Any help would be gladly appreciated!</p>