HHH-16221 Improve extensibility of CockroachDB and PostgreSQL dialects
This commit is contained in:
parent
87bf20f1bb
commit
b328b1a3fb
|
@ -114,8 +114,8 @@ public class CockroachLegacyDialect extends Dialect {
|
||||||
|
|
||||||
// Pre-compile and reuse pattern
|
// Pre-compile and reuse pattern
|
||||||
private static final Pattern CRDB_VERSION_PATTERN = Pattern.compile( "v[\\d]+(\\.[\\d]+)?(\\.[\\d]+)?" );
|
private static final Pattern CRDB_VERSION_PATTERN = Pattern.compile( "v[\\d]+(\\.[\\d]+)?(\\.[\\d]+)?" );
|
||||||
private static final DatabaseVersion DEFAULT_VERSION = DatabaseVersion.make( 19, 2 );
|
protected static final DatabaseVersion DEFAULT_VERSION = DatabaseVersion.make( 19, 2 );
|
||||||
private final PostgreSQLDriverKind driverKind;
|
protected final PostgreSQLDriverKind driverKind;
|
||||||
|
|
||||||
public CockroachLegacyDialect() {
|
public CockroachLegacyDialect() {
|
||||||
this( DEFAULT_VERSION );
|
this( DEFAULT_VERSION );
|
||||||
|
@ -322,7 +322,10 @@ public class CockroachLegacyDialect extends Dialect {
|
||||||
@Override
|
@Override
|
||||||
public void contributeTypes(TypeContributions typeContributions, ServiceRegistry serviceRegistry) {
|
public void contributeTypes(TypeContributions typeContributions, ServiceRegistry serviceRegistry) {
|
||||||
super.contributeTypes( typeContributions, serviceRegistry );
|
super.contributeTypes( typeContributions, serviceRegistry );
|
||||||
|
contributeCockroachTypes( typeContributions, serviceRegistry );
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void contributeCockroachTypes(TypeContributions typeContributions, ServiceRegistry serviceRegistry) {
|
||||||
final JdbcTypeRegistry jdbcTypeRegistry = typeContributions.getTypeConfiguration()
|
final JdbcTypeRegistry jdbcTypeRegistry = typeContributions.getTypeConfiguration()
|
||||||
.getJdbcTypeRegistry();
|
.getJdbcTypeRegistry();
|
||||||
jdbcTypeRegistry.addDescriptor( TIMESTAMP_UTC, InstantAsTimestampWithTimeZoneJdbcType.INSTANCE );
|
jdbcTypeRegistry.addDescriptor( TIMESTAMP_UTC, InstantAsTimestampWithTimeZoneJdbcType.INSTANCE );
|
||||||
|
|
|
@ -156,7 +156,7 @@ public class PostgreSQLLegacyDialect extends Dialect {
|
||||||
|
|
||||||
private static final PostgreSQLIdentityColumnSupport IDENTITY_COLUMN_SUPPORT = new PostgreSQLIdentityColumnSupport();
|
private static final PostgreSQLIdentityColumnSupport IDENTITY_COLUMN_SUPPORT = new PostgreSQLIdentityColumnSupport();
|
||||||
|
|
||||||
private final PostgreSQLDriverKind driverKind;
|
protected final PostgreSQLDriverKind driverKind;
|
||||||
private final UniqueDelegate uniqueDelegate = new CreateTableUniqueDelegate(this);
|
private final UniqueDelegate uniqueDelegate = new CreateTableUniqueDelegate(this);
|
||||||
|
|
||||||
public PostgreSQLLegacyDialect() {
|
public PostgreSQLLegacyDialect() {
|
||||||
|
@ -1314,7 +1314,10 @@ public class PostgreSQLLegacyDialect extends Dialect {
|
||||||
@Override
|
@Override
|
||||||
public void contributeTypes(TypeContributions typeContributions, ServiceRegistry serviceRegistry) {
|
public void contributeTypes(TypeContributions typeContributions, ServiceRegistry serviceRegistry) {
|
||||||
super.contributeTypes( typeContributions, serviceRegistry );
|
super.contributeTypes( typeContributions, serviceRegistry );
|
||||||
|
contributePostgreSQLTypes( typeContributions, serviceRegistry );
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void contributePostgreSQLTypes(TypeContributions typeContributions, ServiceRegistry serviceRegistry) {
|
||||||
final JdbcTypeRegistry jdbcTypeRegistry = typeContributions.getTypeConfiguration()
|
final JdbcTypeRegistry jdbcTypeRegistry = typeContributions.getTypeConfiguration()
|
||||||
.getJdbcTypeRegistry();
|
.getJdbcTypeRegistry();
|
||||||
// For discussion of BLOB support in Postgres, as of 8.4, have a peek at
|
// For discussion of BLOB support in Postgres, as of 8.4, have a peek at
|
||||||
|
|
|
@ -122,9 +122,9 @@ public class CockroachDialect extends Dialect {
|
||||||
// Pre-compile and reuse pattern
|
// Pre-compile and reuse pattern
|
||||||
private static final Pattern CRDB_VERSION_PATTERN = Pattern.compile( "v[\\d]+(\\.[\\d]+)?(\\.[\\d]+)?" );
|
private static final Pattern CRDB_VERSION_PATTERN = Pattern.compile( "v[\\d]+(\\.[\\d]+)?(\\.[\\d]+)?" );
|
||||||
|
|
||||||
private static final DatabaseVersion MINIMUM_VERSION = DatabaseVersion.make( 21, 1 );
|
protected static final DatabaseVersion MINIMUM_VERSION = DatabaseVersion.make( 21, 1 );
|
||||||
|
|
||||||
private final PostgreSQLDriverKind driverKind;
|
protected final PostgreSQLDriverKind driverKind;
|
||||||
|
|
||||||
public CockroachDialect() {
|
public CockroachDialect() {
|
||||||
this( MINIMUM_VERSION );
|
this( MINIMUM_VERSION );
|
||||||
|
@ -333,7 +333,10 @@ public class CockroachDialect extends Dialect {
|
||||||
@Override
|
@Override
|
||||||
public void contributeTypes(TypeContributions typeContributions, ServiceRegistry serviceRegistry) {
|
public void contributeTypes(TypeContributions typeContributions, ServiceRegistry serviceRegistry) {
|
||||||
super.contributeTypes( typeContributions, serviceRegistry );
|
super.contributeTypes( typeContributions, serviceRegistry );
|
||||||
|
contributeCockroachTypes( typeContributions, serviceRegistry );
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void contributeCockroachTypes(TypeContributions typeContributions, ServiceRegistry serviceRegistry) {
|
||||||
final JdbcTypeRegistry jdbcTypeRegistry = typeContributions.getTypeConfiguration()
|
final JdbcTypeRegistry jdbcTypeRegistry = typeContributions.getTypeConfiguration()
|
||||||
.getJdbcTypeRegistry();
|
.getJdbcTypeRegistry();
|
||||||
jdbcTypeRegistry.addDescriptor( TIMESTAMP_UTC, InstantAsTimestampWithTimeZoneJdbcType.INSTANCE );
|
jdbcTypeRegistry.addDescriptor( TIMESTAMP_UTC, InstantAsTimestampWithTimeZoneJdbcType.INSTANCE );
|
||||||
|
|
|
@ -136,12 +136,12 @@ import static org.hibernate.type.descriptor.DateTimeUtils.appendAsTimestampWithM
|
||||||
* @author Gavin King
|
* @author Gavin King
|
||||||
*/
|
*/
|
||||||
public class PostgreSQLDialect extends Dialect {
|
public class PostgreSQLDialect extends Dialect {
|
||||||
private final static DatabaseVersion MINIMUM_VERSION = DatabaseVersion.make( 10 );
|
protected final static DatabaseVersion MINIMUM_VERSION = DatabaseVersion.make( 10 );
|
||||||
|
|
||||||
private static final PostgreSQLIdentityColumnSupport IDENTITY_COLUMN_SUPPORT = new PostgreSQLIdentityColumnSupport();
|
private static final PostgreSQLIdentityColumnSupport IDENTITY_COLUMN_SUPPORT = new PostgreSQLIdentityColumnSupport();
|
||||||
private final UniqueDelegate uniqueDelegate = new CreateTableUniqueDelegate(this);
|
private final UniqueDelegate uniqueDelegate = new CreateTableUniqueDelegate(this);
|
||||||
|
|
||||||
private final PostgreSQLDriverKind driverKind;
|
protected final PostgreSQLDriverKind driverKind;
|
||||||
private final OptionalTableUpdateStrategy optionalTableUpdateStrategy;
|
private final OptionalTableUpdateStrategy optionalTableUpdateStrategy;
|
||||||
|
|
||||||
public PostgreSQLDialect() {
|
public PostgreSQLDialect() {
|
||||||
|
@ -1308,7 +1308,15 @@ public class PostgreSQLDialect extends Dialect {
|
||||||
@Override
|
@Override
|
||||||
public void contributeTypes(TypeContributions typeContributions, ServiceRegistry serviceRegistry) {
|
public void contributeTypes(TypeContributions typeContributions, ServiceRegistry serviceRegistry) {
|
||||||
super.contributeTypes(typeContributions, serviceRegistry);
|
super.contributeTypes(typeContributions, serviceRegistry);
|
||||||
|
contributePostgreSQLTypes(typeContributions, serviceRegistry);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allow for extension points to override this only
|
||||||
|
* @param typeContributions
|
||||||
|
* @param serviceRegistry
|
||||||
|
*/
|
||||||
|
protected void contributePostgreSQLTypes(TypeContributions typeContributions, ServiceRegistry serviceRegistry) {
|
||||||
final JdbcTypeRegistry jdbcTypeRegistry = typeContributions.getTypeConfiguration()
|
final JdbcTypeRegistry jdbcTypeRegistry = typeContributions.getTypeConfiguration()
|
||||||
.getJdbcTypeRegistry();
|
.getJdbcTypeRegistry();
|
||||||
// For discussion of BLOB support in Postgres, as of 8.4, have a peek at
|
// For discussion of BLOB support in Postgres, as of 8.4, have a peek at
|
||||||
|
|
Loading…
Reference in New Issue