@@ -18,6 +18,7 @@ public open class H2(public val dialect: DbType = MySql) : DbType("h2") {
1818 require(dialect::class != H2 ::class ) { " H2 database could not be specified with H2 dialect!" }
1919 }
2020
21+
2122 /* *
2223 * It contains constants related to different database modes.
2324 *
@@ -29,16 +30,36 @@ public open class H2(public val dialect: DbType = MySql) : DbType("h2") {
2930 * @see [createH2Instance]
3031 */
3132 public companion object {
32- /* * It represents the mode value "MySQL" for the H2 database. */
33- public const val MODE_MYSQL : String = " MySQL"
33+ /* *
34+ * Represents the compatibility modes supported by an H2 database.
35+ *
36+ * @property value The string value used in H2 JDBC URL and settings.
37+ */
38+ public enum class Mode (public val value : String ) {
39+ MySql (" MySQL" ),
40+ PostgreSql (" PostgreSQL" ),
41+ MsSqlServer (" MSSQLServer" ),
42+ MariaDb (" MariaDB" );
3443
35- /* * It represents the mode value "PostgreSQL" for the H2 database. */
36- public const val MODE_POSTGRESQL : String = " PostgreSQL"
44+ public companion object {
45+ /* *
46+ * Finds a Mode by its string value (case-insensitive).
47+ *
48+ * @param value The string value to search for.
49+ * @return The matching Mode, or null if not found.
50+ */
51+ public fun fromValue (value : String ): Mode ? =
52+ entries.find { it.value.equals(value, ignoreCase = true ) }
53+ }
54+ }
3755
38- /* * It represents the mode value "MSSQLServer" for the H2 database. */
56+ @Deprecated(" Use Mode.MySql.value instead" , ReplaceWith (" Mode.MySql.value" ))
57+ public const val MODE_MYSQL : String = " MySQL"
58+ @Deprecated(" Use Mode.PostgreSql.value instead" , ReplaceWith (" Mode.PostgreSql.value" ))
59+ public const val MODE_POSTGRESQL : String = " PostgreSQL"
60+ @Deprecated(" Use Mode.MsSqlServer.value instead" , ReplaceWith (" Mode.MsSqlServer.value" ))
3961 public const val MODE_MSSQLSERVER : String = " MSSQLServer"
40-
41- /* * It represents the mode value "MariaDB" for the H2 database. */
62+ @Deprecated(" Use Mode.MariaDb.value instead" , ReplaceWith (" Mode.MariaDb.value" ))
4263 public const val MODE_MARIADB : String = " MariaDB"
4364 }
4465
0 commit comments