title: problem in saving table to database using hibernate using hibernate.hbm2ddl.auto , getting run-time exception
body: <p>I am trying to map my java object to MySQL database using <strong>hibernate</strong> but i am getting following exception </p>
  
  <pre><code>Exception in thread "main" org.springframework.dao.InvalidDataAccessResourceUsageException: could not retrieve snapshot: [hibernate.Employee#125]; SQL [select employee_.Id, employee_.version as version0_, employee_.Name as Name0_, employee_.Age as Age0_, employee_.Salary as Salary0_ from Employee employee_ where employee_.Id=?]; nested exception is org.hibernate.exception.SQLGrammarException: could not retrieve snapshot: [hibernate.Employee#125]
      at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:629)
      at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412)
      at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:411)
      at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:339)
      at hibernate.EmployeeDao.saveOrUpdate(EmployeeDao.java:41)
      at hibernate.SpringHibernateTest.main(SpringHibernateTest.java:24)
  Caused by: org.hibernate.exception.SQLGrammarException: could not retrieve snapshot: [hibernate.Employee#125]
      at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:92)
      at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
      at org.hibernate.persister.entity.AbstractEntityPersister.getDatabaseSnapshot(AbstractEntityPersister.java:1137)
      at org.hibernate.engine.StatefulPersistenceContext.getDatabaseSnapshot(StatefulPersistenceContext.java:292)
      at org.hibernate.engine.ForeignKeys.isTransient(ForeignKeys.java:211)
      at org.hibernate.event.def.AbstractSaveEventListener.getEntityState(AbstractSaveEventListener.java:531)
      at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:103)
      at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:93)
      at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:685)
      at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:677)
      at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:673)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.springframework.orm.hibernate3.HibernateTemplate$CloseSuppressingInvocationHandler.invoke(HibernateTemplate.java:1282)
      at $Proxy0.saveOrUpdate(Unknown Source)
      at hibernate.EmployeeDao$2.doInHibernate(EmployeeDao.java:37)
  </code></pre>
  
  <p>I have used <strong>hibernate.hbm2ddl.auto = update</strong> here is my spring-hibernate.xml file</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.springframework.org/schema/beans 
  http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"&gt;
  
  &lt;bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource" &gt;
      &lt;property name="driverClassName" value="com.mysql.jdbc.Driver"/&gt;
      &lt;property name="url" value="jdbc:mysql://localhost/subhash"/&gt;
      &lt;property name="username" value="root"/&gt;
      &lt;property name="password" value="pass"/&gt;
  &lt;/bean&gt;
  &lt;bean id="mySessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"&gt;
      &lt;property name="dataSource" ref="myDataSource"/&gt;
      &lt;property name="mappingResources"&gt;
          &lt;list&gt;
              &lt;value&gt;employee.hbm.xml&lt;/value&gt;
          &lt;/list&gt;
      &lt;/property&gt;
      &lt;!-- &lt;property name="hibernateProperties"&gt;
          &lt;value&gt;hibernate.dialect=org.hibernate.dialect.HSQLDialect&lt;/value&gt;
      &lt;/property&gt; --&gt;
      &lt;property name="hibernateProperties"&gt;
          &lt;props&gt;
          &lt;prop key="hibernate.dialect"&gt; org.hibernate.dialect.HSQLDialect&lt;/prop&gt;
          &lt;prop key="hibernate.show_sql"&gt;true&lt;/prop&gt;
          &lt;prop key="hibernate.hbm2ddl.auto"&gt;update&lt;/prop&gt;
          &lt;/props&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  &lt;bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate"&gt;
      &lt;property name="sessionFactory"&gt;
          &lt;ref bean="mySessionFactory"/&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  &lt;bean id="employeeDao" class="hibernate.EmployeeDao"&gt;
      &lt;property name="hibernateTemplate"&gt;
          &lt;ref bean="hibernateTemplate"/&gt;    
      &lt;/property&gt;
  &lt;/bean&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p>CAn some one please help me in resolving the error</p>