Background
Part of adapting Hibernate ORM (fork-7.4) for GaussDB. GaussDB 505.2 exposes two
compatibility modes via pg_database.datcompatibility:
- A-mode (Oracle-compatible) — the default
- M-mode / B (MySQL-compatible)
The two modes differ in identifier quoting, type mapping, sequence support,
generated-key retrieval, and keyword reservation, so a single static dialect cannot
serve both correctly.
Changes
-
hibernate-community-dialects
** GaussDBDialect now detects the compatibility mode — explicit config
hibernate.dialect.gaussdb.compatibility_mode, falling back to probing
datcompatibility — and applies mode-specific overrides (column types,
identifier quoting, CHAR/TEXT/CLOB hand.
** Added JdbcTypes: Array, Boolean, Instant, LocalDate, LocalDateTime,
OffsetDateTime, TimestampWithTimeZone.
** Enhanced FunctionRegistry, ExtractFunction, MinMax/JsonObject functions,
AggregateSupport, SqlAstTranslator, LockingSupport.
** M-mode dedicated sequence support: GaussDBMModeSequenceInformationExtractor /
GaussDBMModeSequenceSupport (M mode has no sequence view). -
hibernate-core (tests)
** Test cases relying on features unsupported under A-mode or M-mode are
proactively skipped for the corresponding mode. This does not affect the use
of these test cases with other databases. -
hibernate-testing
** Adapted PostgreSQLDatabaseCleaner, SharedDriverManagerConnectionProvider,
DialectFeatureChecks for GaussDB. -
build
** GaussDB 505.2 version/profile configuration (gradle.properties, local-build-plugins).
Why
To provide support for both A-mode and M-mode in GaussDB, the dialect must branch on
datcompatibility and override SQL generation accordingly; otherwise Hibernate emits
SQL valid only in one mode (e.g. double-quote identifiers in M mode, or clob/sequence
syntax that M mode rejects). Skipping mode-incompatible tests keeps the suite green on
GaussDB without weakening coverage on other databases.