Search in sources :

Example 1 with JavaObjectType

use of org.hibernate.type.JavaObjectType 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)

Example 2 with JavaObjectType

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

the class PostgreSQLDialect method contributeTypes.

@Override
public void contributeTypes(TypeContributions typeContributions, ServiceRegistry serviceRegistry) {
    super.contributeTypes(typeContributions, serviceRegistry);
    final JdbcTypeRegistry jdbcTypeRegistry = typeContributions.getTypeConfiguration().getJdbcTypeRegistry();
    // For discussion of BLOB support in Postgres, as of 8.4, have a peek at
    // <a href="http://jdbc.postgresql.org/documentation/84/binary-data.html">http://jdbc.postgresql.org/documentation/84/binary-data.html</a>.
    // For the effects in regards to Hibernate see <a href="http://in.relation.to/15492.lace">http://in.relation.to/15492.lace</a>
    // Force BLOB binding.  Otherwise, byte[] fields annotated
    // with @Lob will attempt to use
    // BlobTypeDescriptor.PRIMITIVE_ARRAY_BINDING.  Since the
    // dialect uses oid for Blobs, byte arrays cannot be used.
    jdbcTypeRegistry.addDescriptor(Types.BLOB, BlobJdbcType.BLOB_BINDING);
    jdbcTypeRegistry.addDescriptor(Types.CLOB, ClobJdbcType.CLOB_BINDING);
    if (driverKind == PostgreSQLDriverKind.PG_JDBC) {
        jdbcTypeRegistry.addDescriptorIfAbsent(PostgreSQLInetJdbcType.INSTANCE);
        jdbcTypeRegistry.addDescriptorIfAbsent(PostgreSQLIntervalSecondJdbcType.INSTANCE);
        if (getVersion().isSameOrAfter(8, 2)) {
            // HHH-9562
            jdbcTypeRegistry.addDescriptorIfAbsent(UUIDJdbcType.INSTANCE);
            if (getVersion().isSameOrAfter(9, 2)) {
                jdbcTypeRegistry.addDescriptorIfAbsent(PostgreSQLJsonbJdbcType.INSTANCE);
            }
        }
    }
    // PostgreSQL requires a custom binder for binding untyped nulls as VARBINARY
    typeContributions.contributeJdbcType(ObjectNullAsBinaryTypeJdbcType.INSTANCE);
    // Until we remove StandardBasicTypes, we have to keep this
    typeContributions.contributeType(new JavaObjectType(ObjectNullAsBinaryTypeJdbcType.INSTANCE, typeContributions.getTypeConfiguration().getJavaTypeRegistry().getDescriptor(Object.class)));
}
Also used : JdbcTypeRegistry(org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry) JavaObjectType(org.hibernate.type.JavaObjectType)

Example 3 with JavaObjectType

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

the class DerbyDialect method contributeTypes.

@Override
public void contributeTypes(TypeContributions typeContributions, ServiceRegistry serviceRegistry) {
    super.contributeTypes(typeContributions, serviceRegistry);
    final JdbcTypeRegistry jdbcTypeRegistry = typeContributions.getTypeConfiguration().getJdbcTypeRegistry();
    if (getVersion().isBefore(10, 7)) {
        jdbcTypeRegistry.addDescriptor(Types.BOOLEAN, SmallIntJdbcType.INSTANCE);
    }
    jdbcTypeRegistry.addDescriptor(Types.NUMERIC, DecimalJdbcType.INSTANCE);
    jdbcTypeRegistry.addDescriptor(Types.TIMESTAMP_WITH_TIMEZONE, TimestampJdbcType.INSTANCE);
    // Derby requires a custom binder for binding untyped nulls that resolves the type through the statement
    typeContributions.contributeJdbcType(ObjectNullResolvingJdbcType.INSTANCE);
    // Until we remove StandardBasicTypes, we have to keep this
    typeContributions.contributeType(new JavaObjectType(ObjectNullResolvingJdbcType.INSTANCE, typeContributions.getTypeConfiguration().getJavaTypeRegistry().getDescriptor(Object.class)));
}
Also used : JdbcTypeRegistry(org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry) JavaObjectType(org.hibernate.type.JavaObjectType)

Example 4 with JavaObjectType

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

the class SybaseDialect method contributeTypes.

@Override
public void contributeTypes(TypeContributions typeContributions, ServiceRegistry serviceRegistry) {
    super.contributeTypes(typeContributions, serviceRegistry);
    final JdbcTypeRegistry jdbcTypeRegistry = typeContributions.getTypeConfiguration().getJdbcTypeRegistry();
    if (jtdsDriver) {
        jdbcTypeRegistry.addDescriptor(Types.TINYINT, SmallIntJdbcType.INSTANCE);
        // The jTDS driver doesn't support the JDBC4 signatures using 'long length' for stream bindings
        jdbcTypeRegistry.addDescriptor(Types.CLOB, ClobJdbcType.CLOB_BINDING);
        // The jTDS driver doesn't support nationalized types
        jdbcTypeRegistry.addDescriptor(Types.NCLOB, ClobJdbcType.CLOB_BINDING);
        jdbcTypeRegistry.addDescriptor(Types.NVARCHAR, ClobJdbcType.CLOB_BINDING);
    } else {
        // Some Sybase drivers cannot support getClob.  See HHH-7889
        jdbcTypeRegistry.addDescriptor(Types.CLOB, ClobJdbcType.STREAM_BINDING_EXTRACTING);
    }
    jdbcTypeRegistry.addDescriptor(Types.BLOB, BlobJdbcType.PRIMITIVE_ARRAY_BINDING);
    // Sybase requires a custom binder for binding untyped nulls with the NULL type
    typeContributions.contributeJdbcType(ObjectNullAsNullTypeJdbcType.INSTANCE);
    // Until we remove StandardBasicTypes, we have to keep this
    typeContributions.contributeType(new JavaObjectType(ObjectNullAsNullTypeJdbcType.INSTANCE, typeContributions.getTypeConfiguration().getJavaTypeRegistry().getDescriptor(Object.class)));
}
Also used : JdbcTypeRegistry(org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry) JavaObjectType(org.hibernate.type.JavaObjectType)

Example 5 with JavaObjectType

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

the class DB2Dialect method contributeTypes.

@Override
public void contributeTypes(TypeContributions typeContributions, ServiceRegistry serviceRegistry) {
    super.contributeTypes(typeContributions, serviceRegistry);
    final JdbcTypeRegistry jdbcTypeRegistry = typeContributions.getTypeConfiguration().getJdbcTypeRegistry();
    if (getDB2Version().isBefore(11)) {
        jdbcTypeRegistry.addDescriptor(Types.BOOLEAN, SmallIntJdbcType.INSTANCE);
        // Binary literals were only added in 11. See https://www.ibm.com/support/knowledgecenter/SSEPGG_11.1.0/com.ibm.db2.luw.sql.ref.doc/doc/r0000731.html#d79816e393
        jdbcTypeRegistry.addDescriptor(Types.VARBINARY, VarbinaryJdbcType.INSTANCE_WITHOUT_LITERALS);
        if (getDB2Version().isBefore(9, 7)) {
            jdbcTypeRegistry.addDescriptor(Types.NUMERIC, DecimalJdbcType.INSTANCE);
        }
    }
    // See HHH-12753
    // It seems that DB2's JDBC 4.0 support as of 9.5 does not
    // support the N-variant methods like NClob or NString.
    // Therefore here we overwrite the sql type descriptors to
    // use the non-N variants which are supported.
    jdbcTypeRegistry.addDescriptor(Types.NCHAR, CharJdbcType.INSTANCE);
    jdbcTypeRegistry.addDescriptor(Types.NCLOB, useInputStreamToInsertBlob() ? ClobJdbcType.STREAM_BINDING : ClobJdbcType.CLOB_BINDING);
    jdbcTypeRegistry.addDescriptor(Types.NVARCHAR, VarcharJdbcType.INSTANCE);
    jdbcTypeRegistry.addDescriptor(Types.NUMERIC, DecimalJdbcType.INSTANCE);
    // DB2 requires a custom binder for binding untyped nulls that resolves the type through the statement
    typeContributions.contributeJdbcType(ObjectNullResolvingJdbcType.INSTANCE);
    // Until we remove StandardBasicTypes, we have to keep this
    typeContributions.contributeType(new JavaObjectType(ObjectNullResolvingJdbcType.INSTANCE, typeContributions.getTypeConfiguration().getJavaTypeRegistry().getDescriptor(Object.class)));
}
Also used : JdbcTypeRegistry(org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry) JavaObjectType(org.hibernate.type.JavaObjectType)

Aggregations

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