title: org.hibernate.exception.SQLGrammarException: could not execute statement
body: <p>I tried easy program at Hibernate and caught bunch of exception.</p>
  
  <p>I couldn't figure out what exactly is wrong.</p>
  
  <p>I have three classes - Book, Reader and Using. The last is binding first two with dependency one to many.</p>
  
  <p>Here is my <code>main()</code>:</p>
  
  <pre><code>public class Appl {
      public static void main(String[] args) {
          Book book = new Book();
          book.setTitle("book01155");
          //
          Reader reader = new Reader();
          reader.setName("reader2");
          //
          Using using = new Using();
          using.setIdBook(book);
          using.setIdReader(reader);
          //
          List&lt;Book&gt; elements = new ArrayList&lt;Book&gt;();
          //
          Session session = null;     
          try {
              session = HibernateUtil.getSessionFactory().openSession();
              session.beginTransaction();
              session.save(book);
              session.save(reader);
              session.save(using);
              elements = session.createCriteria(Book.class).list();
              session.getTransaction().commit();
          } finally {
              if (session != null &amp;&amp; session.isOpen()) {
                  session.close();
              }
          }
          for (Book b : elements) {
              System.out.println("book: id=" + b.getIdBook() + " Title="
                      + b.getTitle());
          }
          System.out.println("\nThe END.\n");
      }
  }
  </code></pre>
  
  <p>Here is exception message:</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 'USING (IDBOOK, IDREADER) values (2, 2)' at line 1
  Exception in thread "main" org.hibernate.exception.SQLGrammarException: could not execute statement
      at org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert(SQLExceptionTypeDelegate.java:82)
      at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:49)
      at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:125)
  </code></pre>
  
  <p>snippet of <code>hiberante.cfg.xml</code>:</p>
  
  <pre><code>&lt;hibernate-configuration&gt;
      &lt;session-factory&gt;
          &lt;property name="eclipse.connection.profile"&gt;097Hibernate&lt;/property&gt;
  
          &lt;property name="connection.url"&gt;jdbc:mysql://localhost/_097_Library&lt;/property&gt;
          &lt;property name="connection.username"&gt;root&lt;/property&gt;
          &lt;property name="connection.password"&gt;secret&lt;/property&gt;
  
          &lt;!-- property name="hbm2ddl.auto"&gt;create&lt;/property --&gt;
          &lt;property name="hbm2ddl.auto"&gt;update&lt;/property&gt;
  
          &lt;property name="connection.driver_class"&gt;
              com.mysql.jdbc.Driver
          &lt;/property&gt;
  
          &lt;property name="dialect"&gt;
              org.hibernate.dialect.MySQLDialect
          &lt;/property&gt;
  
          &lt;mapping class="com.softserve.edu.Book" /&gt;
          &lt;mapping class="com.softserve.edu.Reader" /&gt;
          &lt;mapping class="com.softserve.edu.Using" /&gt;
      &lt;/session-factory&gt;
  &lt;/hibernate-configuration&gt;
  </code></pre>
  
  <p>All tables at DB are created but is empty.
  All looks ok. Any suggestions?</p>
  
  <ul>
  <li><em><strong>How to solve this trouble?</em></strong></li>
  </ul>