diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/DatabaseVersion.java b/hibernate-core/src/main/java/org/hibernate/dialect/DatabaseVersion.java index f4d2b7c6d0..e95d6f6c47 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/DatabaseVersion.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/DatabaseVersion.java @@ -38,6 +38,19 @@ public interface DatabaseVersion { */ int getDatabaseMinorVersion(); + /** + * Get a simple int representing the version based on the formula + * {@code ({major) * 10000}) + (minor * 1000)} where minor == {@link #NO_VERSION} + * is normalized to zero + */ + default int getCanonicalVersion() { + final int major = getDatabaseMajorVersion(); + final int minor = getDatabaseMinorVersion() == NO_VERSION + ? 0 + : getDatabaseMinorVersion(); + return ( major * 10000 ) + ( minor * 1000 ); + } + default boolean isAfter(DatabaseVersion other) { return isAfter( other.getDatabaseMajorVersion(), other.getDatabaseMinorVersion() ); }