I'm having the same problem as the person who initiated this thread.
I'm new to Hibernate and Ant and I'm trying to run the tutorial.
As long as I leave the hbm2ddl.auto statement in the hibernate.cfg.xml, both the -Daction=store and -Daction=list commands run without errors.
I've tried
1) ant run -Daction=store (runs without error, last message from ant is [java] Hibernate: insert into EVENTS ... )
2) editing the hibernate.cfg.xml and deleting the line:
<property name="hbm2ddl.auto">create</property>
3) ant run -Daction=store
this time I get an unhandled exception for which the stack trace starts with:
Code:
[java] 16:34:55,100 WARN JDBCExceptionReporter:71 - SQL Error: -22, SQLState: S0002
[java] 16:34:55,103 ERROR JDBCExceptionReporter:72 - Table not found in statement [select max(EVENT_ID) from EVENTS]
[java] Exception in thread "main" org.hibernate.exception.SQLGrammarException: could not fetch initial value
So, as far as I can tell, each time I run the tutorial, the in memory database starts up totally empty. It isn't persisting anything between runs of the program. As a result, if I don't have the hdm2dll.auto statement in the cfg.xml file, there is no table to store into or list from so the example breaks. If I do have the hdb2dll.auto statement present, then the EVENTS table is created and the code works, but never displays anything.
So my question is:
Am I doing something wrong, or is the tutorial incapable of operating as it describes:
Quote:
The reason for this is the hbm2ddl.auto switch in the Hibernate configuration: Hibernate will re-create the database on every run. Disable it by removing the option, and you will see results in your list after you called the store action a few times. Automatic schema generation and export is mostly useful in unit testing.
Thanks for your help,
Steve