Search in sources :

Example 1 with NullType

use of org.hibernate.type.NullType in project hibernate-orm by hibernate.

the class MySQLDialect method contributeTypes.

@Override
public void contributeTypes(TypeContributions typeContributions, ServiceRegistry serviceRegistry) {
    super.contributeTypes(typeContributions, serviceRegistry);
    final JdbcTypeRegistry jdbcTypeRegistry = typeContributions.getTypeConfiguration().getJdbcTypeRegistry();
    if (getMySQLVersion().isSameOrAfter(5, 7)) {
        jdbcTypeRegistry.addDescriptorIfAbsent(SqlTypes.JSON, JsonJdbcType.INSTANCE);
    }
    // MySQL requires a custom binder for binding untyped nulls with the NULL type
    typeContributions.contributeJdbcType(NullJdbcType.INSTANCE);
    // Until we remove StandardBasicTypes, we have to keep this
    typeContributions.contributeType(new NullType(NullJdbcType.INSTANCE, typeContributions.getTypeConfiguration().getJavaTypeRegistry().getDescriptor(Object.class)));
}
Also used : NullType(org.hibernate.type.NullType) JdbcTypeRegistry(org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry)

Example 2 with NullType

use of org.hibernate.type.NullType in project hibernate-orm by hibernate.

the class OracleDialect method contributeTypes.

@Override
public void contributeTypes(TypeContributions typeContributions, ServiceRegistry serviceRegistry) {
    super.contributeTypes(typeContributions, serviceRegistry);
    if (getVersion().isSameOrAfter(12)) {
        // account for Oracle's deprecated support for LONGVARBINARY
        // prefer BLOB, unless the user explicitly opts out
        boolean preferLong = serviceRegistry.getService(ConfigurationService.class).getSetting(PREFER_LONG_RAW, StandardConverters.BOOLEAN, false);
        BlobJdbcType descriptor = preferLong ? BlobJdbcType.PRIMITIVE_ARRAY_BINDING : BlobJdbcType.DEFAULT;
        typeContributions.contributeJdbcType(descriptor);
    }
    // Oracle requires a custom binder for binding untyped nulls with the NULL type
    typeContributions.contributeJdbcType(NullJdbcType.INSTANCE);
    typeContributions.contributeJdbcType(ObjectNullAsNullTypeJdbcType.INSTANCE);
    // Until we remove StandardBasicTypes, we have to keep this
    typeContributions.contributeType(new NullType(NullJdbcType.INSTANCE, typeContributions.getTypeConfiguration().getJavaTypeRegistry().getDescriptor(Object.class)));
    typeContributions.contributeType(new JavaObjectType(ObjectNullAsNullTypeJdbcType.INSTANCE, typeContributions.getTypeConfiguration().getJavaTypeRegistry().getDescriptor(Object.class)));
}
Also used : ConfigurationService(org.hibernate.engine.config.spi.ConfigurationService) NullType(org.hibernate.type.NullType) BlobJdbcType(org.hibernate.type.descriptor.jdbc.BlobJdbcType) JavaObjectType(org.hibernate.type.JavaObjectType)

Aggregations

NullType (org.hibernate.type.NullType)2 ConfigurationService (org.hibernate.engine.config.spi.ConfigurationService)1 JavaObjectType (org.hibernate.type.JavaObjectType)1 BlobJdbcType (org.hibernate.type.descriptor.jdbc.BlobJdbcType)1 JdbcTypeRegistry (org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry)1