Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I don't think this is supported simply because the script file containing <em>the definition of tables and other database objects, plus the data for non-cached tables</em> is not supposed to contain syntactically incorrect statements (they are supposed to be written by HSQLDB itself).</p> <p>But since you're using Hibernate, my suggestion would to use the <code>import.sql</code> feature announced in the <a href="http://relation.to/9081.lace" rel="nofollow noreferrer">Rotterdam JBug and Hibernate's import.sql</a> blog post:</p> <blockquote> <h3><a href="http://relation.to/Bloggers/RotterdamJBugAndHibernatesImportsql#H-ImportsqlEasilyImportDataInYourUnitTests" rel="nofollow noreferrer">import.sql: easily import data in your unit tests</a></h3> <p>Hibernate has a neat little feature that is heavily under-documented and unknown. You can execute an SQL script during the <code>SessionFactory</code> creation right after the database schema generation to import data in a fresh database. You just need to add a file named <code>import.sql</code> in your classpath root and set either <code>create</code> or <code>create-drop</code> as your <code>hibernate.hbm2ddl.auto</code> property.</p> <p>I use it for <a href="http://www.manning.com/affiliate/idevaffiliate.php?id=952_117_1_24" rel="nofollow noreferrer">Hibernate Search in Action</a> now that I have started the query chapter. It initializes my database with a fresh set of data for my unit tests. JBoss Seam also uses it a lot in the various examples. <code>import.sql</code> is a very simple feature but is quite useful at time. Remember that the SQL might be dependent on your database (ah portability!).</p> <pre><code>#import.sql file delete from PRODUCTS insert into PRODUCTS (PROD_ID, ASIN, TITLE, PRICE, IMAGE_URL, DESCRIPTION) values ('1', '630522577X', 'My Fair Lady', 19.98, '630522577X.jpg', 'My Fair blah blah...'); insert into PRODUCTS (PROD_ID, ASIN, TITLE, PRICE, IMAGE_URL, DESCRIPTION) values ('2', 'B00003CXCD', 'Roman Holiday ', 12.98, 'B00003CXCD.jpg', 'We could argue that blah blah'); </code></pre> <p>For more information about this feature, check <a href="http://www.jroller.com/eyallupu/entry/hibernate_s_hbm2ddl_tool" rel="nofollow noreferrer">Eyal's blog</a>, he wrote a nice little entry about it. Remember if you want to add additional database objects (indexes, tables and so on), you can also use the auxiliary database objects feature.</p> </blockquote> <p>Another option would be to use <a href="http://www.dbunit.org/" rel="nofollow noreferrer">DbUnit</a>. But if (non) portability is not an issue, I'd use the <code>import.sql</code> trick.</p> <h3>Related questions</h3> <ul> <li><a href="https://stackoverflow.com/questions/742004/how-to-execute-differnet-import-sql-in-hibernate-jpa-for-each-persistence-unit">How to execute differnet import.sql in Hibernate/JPA for each persistence unit?</a> </li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload