I wanted to do the schema export (for Hibernate Envers audit tables) from a program rather than an Ant script since I was building the hibernate configuration at runtime.

I had to track down where org.hibernate.tool.ant.EnversHibernateToolTask did it’s magic.

Anyway if anyone finds this googling, here’s how:

AuditConfiguration auditConfig = AuditConfiguration.getFor(aConfig);
new SchemaExport(aConfig).setOutputFile("/some/file").create(false, true);

You can ignore other posts about, hibernate.hbm2ddl.auto=create-drop or update
- it doesn’t matter.
If it wouldn’t also try to re-create my legacy tables, that’d be nice..
this might also be useful