
liquibase.ext.hibernate.diff.MissingIndexChangeGenerator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of liquibase-hibernate4.2 Show documentation
Show all versions of liquibase-hibernate4.2 Show documentation
Liquibase extension for hibernate integration including generating changesets based on changed
hibernate mapping files. Supports Hibernate 4.0 through 4.2.
The newest version!
package liquibase.ext.hibernate.diff;
import liquibase.change.Change;
import liquibase.database.Database;
import liquibase.diff.output.DiffOutputControl;
import liquibase.diff.output.changelog.ChangeGeneratorChain;
import liquibase.ext.hibernate.database.HibernateDatabase;
import liquibase.structure.DatabaseObject;
import liquibase.structure.core.Index;
/**
* Indexes tend to be added in the database that don't correspond to what is in Hibernate, so we suppress all dropIndex changes
* based on indexes defined in the database but not in hibernate.
*/
public class MissingIndexChangeGenerator extends liquibase.diff.output.changelog.core.MissingIndexChangeGenerator {
@Override
public int getPriority(Class extends DatabaseObject> objectType, Database database) {
if (Index.class.isAssignableFrom(objectType)) {
return PRIORITY_ADDITIONAL;
}
return PRIORITY_NONE;
}
@Override
public Change[] fixMissing(DatabaseObject missingObject, DiffOutputControl control, Database referenceDatabase, Database comparisonDatabase, ChangeGeneratorChain chain) {
if (referenceDatabase instanceof HibernateDatabase || comparisonDatabase instanceof HibernateDatabase) {
return null;
} else {
return super.fixMissing(missingObject, control, referenceDatabase, comparisonDatabase, chain);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy