Hi Mike,

Michael Horwitz wrote:
There are a few parameters you will need to change on the hibernate plugin to get it to generate the ddl file. You need to set export, update, create and drop to false as well. You are correct in believing that the plugin will not fire if you set maven.test.skip to true. Note that the hibernate plugin only creates the table structure - the data is imported via the dbUnit plugin.
Thanks for that. I've tweaked my pom.xml and profile.xml so that it runs without error and produces a nice list of DDL statements in the log output, but I can't convince it to create a file :-( Never mind, it's not a huge problem to pipe the output or copy/paste.

I'd be more interested to get dbUnit's SQL statements into a file though. Took a look at their website and couldn't see anything to indicate that kind of functionality is available unfortunately :-(

In case it helps someone else to work out how to get hibernate to spit its ddl out to a file, here's what I've done so far:

In my pom.xml:
1. I located the <hibernate3-maven-plugin> tag and added the following inside its <componentProperties> tag:

   <drop>${hibernate.drop}</drop>
   <update>${hibernate.update}</update>
   <create>${hibernate.create}</create>
   <export>${hibernate.export}</export>
   <outputfilename>${hibernate.outputfilename}</outputfilename>

2. Then I went to the project <properties> tag at the bottom of my pom.xml and added the following:

   <hibernate.export>true</hibernate.export>
   <hibernate.update>false</hibernate.update>
   <hibernate.drop>false</hibernate.drop>
   <hibernate.create>true</hibernate.create>
   <hibernate.outputfilename></hibernate.outputfilename>

Which simply specifies default values (IAW http://www.hibernate.org/hib_docs/tools/reference/en/html_single/#d0e1137 ) for these parameters.

Then I ran my mvn command as follows:

mvn hibernate3:hbm2ddl -Denv=test -Dhibernate.export=false -Dhibernate.outputfilename=oracle.ddl

As I said, this produces a nice output at the console that could be captured into a file, but nothing I tried for the hibernate.outputfilename parameter (full path, / or \ separators (on windoze) etc.) would make it write to a file. Note, I left the "hibernate.create" parameter as "true" because from my reading of the documentation, this means it actually does the "create table" statements.

Cheers,

Rob Hills
Waikiki, Western Australia

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to