title: org.hibernate.exception.SQLGrammarException: could not insert [com.sample.Person]
body: <p>I'm trying to set up a small working sample of Hibernate that I found <a href="http://www.mastertheboss.com/hibernate/182-hibernate-tutorial.html" rel="noreferrer">here</a> However when I run the code I get the follwing error</p>
  
  <pre><code>Exception in thread "main" org.hibernate.exception.SQLGrammarException: could not insert: [com.sample.Person]
  at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:92)
  at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
  at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:64)
  at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2345)
  at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2852)
  at org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:71)
  at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:273)
  at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:320)
  at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:203)
  at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:129)
  at .....
  
  
  Caused by: org.postgresql.util.PSQLException: ERROR: relation "person" does not exist
  Position: 13
  at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2102)
  at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1835)
  at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)
  at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:500)
  at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:388)
  at org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(AbstractJdbc2Statement.java:334)
  at org.hibernate.id.IdentityGenerator$GetGeneratedKeysDelegate.executeAndExtract(IdentityGenerator.java:94)
  at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:57)
  ... 23 more
  </code></pre>
  
  <p>But I already have a table by the name person in the database and here's my modified hibernate.cfg.xml 
      </p>
  
  <p>
      </p>
  
  <pre><code>    &lt;!-- hibernate dialect --&gt;
      &lt;property name="hibernate.dialect"&gt;org.hibernate.dialect.MySQLInnoDBDialect&lt;/property&gt;
  
  
      &lt;property name="hibernate.connection.driver_class"&gt;org.postgresql.Driver&lt;/property&gt;
      &lt;property name="hibernate.connection.url"&gt;jdbc:postgresql://localhost/testDB&lt;/property&gt;
      &lt;property name="hibernate.connection.username"&gt;postgres&lt;/property&gt;
      &lt;property name="hibernate.connection.password"&gt;&lt;/property&gt;
      &lt;property name="hibernate.show.sql" &gt;&lt;/property&gt; 
      &lt;property name="transaction.factory_class"&gt;org.hibernate.transaction.JDBCTransactionFactory&lt;/property&gt;
  
      &lt;!-- Automatic schema creation (begin) === --&gt;
      &lt;property name="hibernate.hbm2ddl.auto"&gt;create&lt;/property&gt;
  
  
      &lt;!-- Simple memory-only cache --&gt;
      &lt;property name="hibernate.cache.provider_class"&gt;org.hibernate.cache.HashtableCacheProvider&lt;/property&gt;
  
      &lt;!-- Enable Hibernate's automatic session context management --&gt;
      &lt;property name="current_session_context_class"&gt;thread&lt;/property&gt;
  
      &lt;!-- ############################################ --&gt;
      &lt;!-- # mapping files with external dependencies # --&gt;
      &lt;!-- ############################################ --&gt;
  
      &lt;mapping resource="com/sample/Person.hbm.xml" /&gt;
  
  &lt;/session-factory&gt;
  </code></pre>
  
  <p></p>
  
  <p>It would be great if anyone could point out what Im doing wrong, as this is my first attempt at Hibernate.
  Thanks!</p>
  
  <p>EDIT: Person.hbm.xml
      </p>
  
  <p></p>
  
  <p></p>
  
  <pre><code>&lt;class name="com.sample.Person" table="person"&gt;
  
      &lt;id name="id" column="ID"&gt;
          &lt;generator class="native" /&gt;
      &lt;/id&gt;
  
      &lt;property name="name"&gt;
          &lt;column name="NAME" length="16" not-null="true" /&gt;
      &lt;/property&gt;
  
      &lt;property name="surname"&gt;
          &lt;column name="SURNAME" length="16" not-null="true" /&gt;
      &lt;/property&gt;
  
      &lt;property name="address"&gt;
          &lt;column name="ADDRESS" length="16" not-null="true" /&gt;
      &lt;/property&gt;
  
  &lt;/class&gt;
  </code></pre>
  
  <p></p>
  
  <p>EDIT-II: Content of the log file (Postgresql.log) </p>
  
  <pre><code> 2012-02-13 09:23:25 IST LOG:  database system was shut down at 2012-02-10 18:14:57 IST
   2012-02-13 09:23:25 IST FATAL:  the database system is starting up
   2012-02-13 09:23:33 IST LOG:  database system is ready to accept connections
   2012-02-13 09:23:38 IST LOG:  autovacuum launcher started
   2012-02-13 09:46:01 IST ERROR:  syntax error at or near "auto_increment" at character 41
      2012-02-13 09:46:01 IST STATEMENT:  create table person (ID bigint not null         auto_increment, NAME varchar(16) not null, SURNAME varchar(16) not null, ADDRESS varchar(16) not null, primary key (ID)) type=InnoDB
   2012-02-13 09:46:01 IST ERROR:  relation "person" does not exist at character 13
  2012-02-13 09:46:01 IST STATEMENT:  insert into person (NAME, SURNAME, ADDRESS) values   ($1, $2, $3) RETURNING *
  2012-02-13 09:46:01 IST LOG:  could not receive data from client: No connection could be made because the target machine actively refused it.
  
  
  2012-02-13 09:46:01 IST LOG:  unexpected EOF on client connection
  2012-02-13 09:48:15 IST ERROR:  syntax error at or near "auto_increment" at character 41
  2012-02-13 09:48:15 IST STATEMENT:  create table person (ID bigint not null auto_increment, NAME varchar(16) not null, SURNAME varchar(16) not null, ADDRESS varchar(16) not null, primary key (ID)) type=InnoDB
  2012-02-13 09:48:15 IST ERROR:  relation "person" does not exist at character 13
  2012-02-13 09:48:15 IST STATEMENT:  insert into person (NAME, SURNAME, ADDRESS) values ($1, $2, $3) RETURNING *
   2012-02-13 09:48:15 IST LOG:  could not receive data from client: No connection could be made because the target machine actively refused it.
  
  
  2012-02-13 09:48:15 IST LOG:  unexpected EOF on client connection
  </code></pre>
  
  <p><strong>UPDATE</strong>: I just noticed something weird, I create the relation in the DB and then run this piece of code, only to see that the table gets deleted as in it just dissapears when I run this code; any idea why this happens? </p>