title: Save embedded HSQL database to file
body: <p>For logging and debugging purposes I want to dump an embedded/in-memory HSQL database to a file. Schema + Data. I'm using the spring-framework with hibernate.</p>
  <p>I've tried both:</p>
  <pre><code>    Session session = sessionFactory.openSession();
      Transaction transaction = session.beginTransaction();
  
      session.createSQLQuery(&quot;BACKUP DATABASE TO '/tmp/backup.tar.gz' BLOCKING&quot;);
  
      transaction.commit();
      session.close();
  </code></pre>
  <p>and</p>
  <pre><code>    Session session = sessionFactory.openSession();
      Transaction transaction = session.beginTransaction();
  
      session.createSQLQuery(&quot;SCRIPT '/tmp/backup-data.sql'&quot;);
  
      transaction.commit();
      session.close();
  </code></pre>
  <p>Both to no avail.</p>
  <p>There is no special configuration.</p>
  <h3>Hibernate config:</h3>
  <pre><code>&lt;jdbc:embedded-database id=&quot;dataSource&quot; type=&quot;HSQL&quot;&gt;
      &lt;jdbc:script location=&quot;classpath:spring/batch/database/schema.sql&quot;/&gt;
  &lt;/jdbc:embedded-database&gt;
  
  &lt;bean id=&quot;sessionFactory&quot;
        class=&quot;org.springframework.orm.hibernate4.LocalSessionFactoryBean&quot;
        p:dataSource-ref=&quot;dataSource&quot;&gt;
      &lt;property name=&quot;packagesToScan&quot; value=&quot;com.domain.*.model&quot;/&gt;
      &lt;property name=&quot;hibernateProperties&quot;&gt;
          &lt;value&gt;
              hibernate.format_sql=true
              hibernate.dialect=org.hibernate.dialect.HSQLDialect
          &lt;/value&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  </code></pre>
  <p>What did I miss, do I need a different approach, is it even possible?</p>