if (dbVersion == null) {
throw new ApplicationContextException("No Version exists for " + product + " in the database. Please check the upgrade instructions for this release.");
}
final Version codeVersion = productVersionEntry.getValue();
final Field mostSpecificMatchingField = VersionUtils.getMostSpecificMatchingField(dbVersion, codeVersion);
switch (mostSpecificMatchingField) {
//Versions completely match
case LOCAL: {
logger.info("Software and Database versions are both {} for {}", dbVersion, product);
continue;
}
//Versions match except for local part
case PATCH:
//Versions match except for patch.local part
case MINOR: {
//If db is before code and auto-update is enabled run hibernate-update
final Field upgradeField = mostSpecificMatchingField.getLessImportant();
if (dbVersion.isBefore(codeVersion) &&
this.updatePolicy != null &&
(upgradeField.equals(this.updatePolicy) || upgradeField.isLessImportantThan(this.updatePolicy))) {
logger.info("Automatically updating database from {} to {} for {}", dbVersion, codeVersion, product);
this.portalShellBuildHelper.hibernateUpdate("automated-hibernate-update", product, true, null);
continue;
}