Skip to content

Commit

Permalink
Use string based storage as fallback for JSON
Browse files Browse the repository at this point in the history
  • Loading branch information
beikov committed Mar 24, 2022
1 parent ad806ff commit 6fd8034
Showing 1 changed file with 14 additions and 3 deletions.
Expand Up @@ -47,7 +47,10 @@
import org.hibernate.type.SqlTypes;
import org.hibernate.type.descriptor.java.spi.JavaTypeRegistry;
import org.hibernate.type.descriptor.jdbc.JdbcType;
import org.hibernate.type.descriptor.jdbc.JsonJdbcType;
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
import org.hibernate.type.descriptor.sql.internal.DdlTypeImpl;
import org.hibernate.type.descriptor.sql.spi.DdlTypeRegistry;
import org.hibernate.type.internal.NamedBasicTypeImpl;
import org.hibernate.type.spi.TypeConfiguration;

Expand Down Expand Up @@ -372,15 +375,23 @@ private static void handleTypes(BootstrapContext bootstrapContext, MetadataBuild
}

// add fallback type descriptors
final JdbcTypeRegistry jdbcTypeRegistry = typeConfiguration
.getJdbcTypeRegistry();
final JdbcTypeRegistry jdbcTypeRegistry = typeConfiguration.getJdbcTypeRegistry();
addFallbackIfNecessary( jdbcTypeRegistry, SqlTypes.UUID, SqlTypes.BINARY );
addFallbackIfNecessary( jdbcTypeRegistry, SqlTypes.JSON, SqlTypes.VARBINARY );
jdbcTypeRegistry.addDescriptorIfAbsent( JsonJdbcType.INSTANCE );
addFallbackIfNecessary( jdbcTypeRegistry, SqlTypes.INET, SqlTypes.VARBINARY );
addFallbackIfNecessary( jdbcTypeRegistry, SqlTypes.INTERVAL_SECOND, SqlTypes.NUMERIC );
addFallbackIfNecessary( jdbcTypeRegistry, SqlTypes.GEOMETRY, SqlTypes.VARBINARY );
addFallbackIfNecessary( jdbcTypeRegistry, SqlTypes.POINT, SqlTypes.VARBINARY );

final DdlTypeRegistry ddlTypeRegistry = typeConfiguration.getDdlTypeRegistry();
ddlTypeRegistry.addDescriptorIfAbsent(
new DdlTypeImpl(
SqlTypes.JSON,
ddlTypeRegistry.getTypeName( SqlTypes.VARCHAR, null, null, null ),
dialect
)
);

// add explicit application registered types
typeConfiguration
.addBasicTypeRegistrationContributions( options.getBasicTypeRegistrations() );
Expand Down

0 comments on commit 6fd8034

Please sign in to comment.