+ getLog().info("Gathered hibernate-configuration (turn on debugging for details):");
+ for (Entry<Object,Object> entry : properties.entrySet())
+ getLog().info(" " + entry.getKey() + " = " + entry.getValue());
+
+ if (!modified)
+ {
+ getLog().info(
+ "No modified annotated classes or mapping-files found and dialect " +
+ "unchanged."
+ );
+ if (!force)
+ {
+ getLog().info("Skipping schema generation!");
+ project.getProperties().setProperty(EXPORT_SKIPPED_PROPERTY, "true");
+ return;
+ }
+ }
+
+ try
+ {
+ /**
+ * The connection must be established outside of hibernate, because
+ * hibernate does not use the context-classloader of the current
+ * thread and, hence, would not be able to resolve the driver-class!
+ */
+ if (!text && (create || drop))
+ {
+ Class driverClass = classLoader.loadClass(properties.getProperty(DRIVER_CLASS));
+ getLog().debug("Registering JDBC-driver " + driverClass.getName());
+ DriverManager.registerDriver(new DriverProxy((Driver)driverClass.newInstance()));
+ getLog().debug(
+ "Opening JDBC-connection to "
+ + properties.getProperty(URL)
+ + " as "
+ + properties.getProperty(USERNAME)
+ + " with password "
+ + properties.getProperty(PASSWORD)
+ );
+ connection = DriverManager.getConnection(
+ properties.getProperty(URL),
+ properties.getProperty(USERNAME),
+ properties.getProperty(PASSWORD)
+ );
+ }
+ }
+ catch (ClassNotFoundException e)
+ {
+ getLog().error("Dependency for driver-class " + properties.getProperty(DRIVER_CLASS) + " is missing!");
+ throw new MojoExecutionException(e.getMessage());
+ }
+ catch (Exception e)
+ {
+ getLog().error("Cannot establish connection to database!");
+ Enumeration<Driver> drivers = DriverManager.getDrivers();
+ if (!drivers.hasMoreElements())
+ getLog().error("No drivers registered!");
+ while (drivers.hasMoreElements())
+ getLog().debug("Driver: " + drivers.nextElement());
+ throw new MojoExecutionException(e.getMessage());
+ }
+
+ config.buildMappings();
+
+ if (envers)
+ {
+ getLog().info("Automatic auditing via hibernate-envers enabled!");
+ AuditConfiguration.getFor(config);
+ }