title: Creating HSQL create table query from class
body: <p>I have a much used project that I am working on currently updating. There are several places where this project can be installed, and in the future it is not certain what version is used where and to what version one might be updated to in the future. Right now they are all the same, though.</p>
  
  <p>My problem stems from the fact that there might be many changes to the hibernate entity classes, and it must be easy to update to a newer version without any hassle, and no loss of database content. Just replace WAR and start and it should migrate itself.</p>
  
  <p>To my knowledge Hibernate does no altering of tables unless <em>hibernate.hbm2ddl.auto=create</em>, but which actually throws away all the data?</p>
  
  <p>So right now when the Spring context has fully loaded, it executes a bean that will migrate the database to the current version by going through all the changes from versionX to versionY (what version it previously was is saved in the database), and manually alter the table.</p>
  
  <p>It's not much hassle doing a few hard-coded ALTER TABLE to add some columns, but when it comes to adding complete new tables, it feels silly to have to write all that...</p>
  
  <p><strong>So my question(s) is this</strong>: </p>
  
  <ul>
  <li><p>Is there any way to send an entity class and a dialect to Hibernate
  code somewhere, and get back a valid SQL query for creating a table?</p></li>
  <li><p>And even better, somehow create an SQL string for adding a column to a table, dialect-safe?</p></li>
  </ul>
  
  <p>I hope this is not a silly question, and I have not missed something obvious when it comes to Hibernate...</p>