import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.project.MavenProject;
import org.hibernate.cfg.Configuration;
+import org.hibernate.envers.configuration.AuditConfiguration;
import org.hibernate.tool.hbm2ddl.SchemaExport;
import org.hibernate.tool.hbm2ddl.SchemaExport.Type;
import org.hibernate.tool.hbm2ddl.Target;
public final static String USERNAME = "hibernate.connection.username";
public final static String PASSWORD = "hibernate.connection.password";
public final static String DIALECT = "hibernate.dialect";
+ public final static String ENVERS = "hibernate.export.envers";
private final static String MD5S = "schema.md5s";
*/
private boolean format;
+ /**
+ * Generate envers schema for auditing tables.
+ *
+ * @parameter expression="${hibernate.export.envers}" default-value="false"
+ */
+ private Boolean envers;
@Override
public void execute()
md5s.put(DIALECT, properties.getProperty(DIALECT));
}
+ if (md5s.containsKey(ENVERS))
+ {
+ String envers = properties.getProperty(ENVERS);
+ if (md5s.get(ENVERS).equals(envers))
+ getLog().debug("Envers unchanged.");
+ else
+ {
+ getLog().debug("Envers changed: " + envers);
+ modified = true;
+ md5s.put(ENVERS, envers.toString());
+ }
+ }
+ else
+ {
+ modified = true;
+ md5s.put(ENVERS, properties.getProperty(ENVERS));
+ }
+
+ if (envers != null) {
+ if (properties.containsKey(ENVERS))
+ getLog().debug(
+ "Overwriting property " +
+ ENVERS + "=" + properties.getProperty(ENVERS) +
+ " with the value " + envers
+ );
+ else
+ getLog().debug("Using the value " + envers);
+ properties.setProperty(ENVERS, envers.toString());
+ }
+
if (properties.isEmpty())
{
getLog().error("No properties set!");
*/
Thread.currentThread().setContextClassLoader(classLoader);
+ config.buildMappings();
+ if ("true".equals(properties.getProperty(ENVERS)))
+ {
+ getLog().debug("Using envers");
+ AuditConfiguration.getFor(config);
+ }
+
SchemaExport export = new SchemaExport(config, connection);
export.setOutputFile(outputFile);
export.setDelimiter(delimiter);