ALQH
ALQH

Reputation: 161

Hibernate SchemaExport command line

I found this documentation http://docs.jboss.org/hibernate/core/4.0/manual/en-US/html/toolsetguide.html#toolsetguide-s1-3 saying that we can run SchemaExport using command line

java -cp hibernate_classpaths org.hibernate.tool.hbm2ddl.SchemaExport options mapping_files 

Can someone please provide an example of how this is used? What is the format of the classpath (perhaps a example classpath), how do I do it with a hbm.xml mapping?

Thanks

Upvotes: 1

Views: 3484

Answers (1)

Yury Shaban
Yury Shaban

Reputation: 105

Not a problem :) Example:

java -cp "hibernate/*" org.hibernate.tool.hbm2ddl.SchemaExport --properties=hibernate.properties --text Person.hbm.xml User.hbm.xml

Here "hibernate/*" means that you have a folder named "hibernate" with all libraries for hibernate (incl. hibernate3 of course).

in my case:

  • antlr-2.7.6.jar
  • cglib-2.2.jar
  • commons-collections-3.1.jar
  • dom4j-1.6.1.jar
  • hibernate-testing.jar
  • hibernate3.jar
  • javassist-3.9.0.GA.jar
  • jta-1.1.jar
  • log4j-1.2.16.jar
  • slf4j-api-1.5.8.jar
  • slf4j-log4j12-1.6.1.jar

You have to put in the current folder the file hibernate.properties (you can use hibernate.cfg.xml, but option will be --config instead of --properties. I.e. "--config=hibernate.cfg.xml")

--text - output to the console Next a list of necessary files *.hbm.xml.

That's all.

Upvotes: 1

Related Questions