-
1. Re: Envers - generate script for AUD tables
damianb Feb 22, 2013 4:40 AM (in response to damianb)This method did the trick for me:
enum Dialect {
MYSQL("org.hibernate.dialect.MySQLInnoDBDialect"),
ORACLE("org.hibernate.dialect.Oracle10gDialect"),
SYBASE("org.hibernate.dialect.SybaseAnywhereDialect");
private String className;
private Dialect(String className) {
this.className = className;
}
public String getClassName() {
return className;
}
}
private void createSchema(Dialect dialect, Class<?>... classes) {
Configuration configuration = new Configuration();
configuration.setProperty(Environment.DIALECT, dialect.getClassName());
for (Class<?> entityClass : classes) {
configuration.addAnnotatedClass(entityClass);
}
configuration.buildMappings();
AuditConfiguration.getFor(configuration);
SchemaExport schemaExport = new SchemaExport(configuration);
schemaExport.setDelimiter(";");
schemaExport.setOutputFile(String.format("%s_%s.%s ", "ddl_audit", dialect.name().toLowerCase(), "sql"));
boolean consolePrint = true;
boolean exportInDatabase = false;
schemaExport.create(consolePrint, exportInDatabase);
}
-
2. Re: Envers - generate script for AUD tables
adamw Mar 1, 2013 12:48 PM (in response to damianb)That's also +/- what the generate-schema ant task does, see:
http://docs.jboss.org/hibernate/core/4.1/devguide/en-US/html/ch15.html#envers-generateschema
and the sources of the ant task.
Adam