org.hibernate.type.descriptor.sql.SqlTypeDescriptor Java Examples

The following examples show how to use org.hibernate.type.descriptor.sql.SqlTypeDescriptor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AttributeConverterTypeAdapter.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
public AttributeConverterTypeAdapter(
		String name,
		String description,
		JpaAttributeConverter<? extends T,?> attributeConverter,
		SqlTypeDescriptor sqlTypeDescriptorAdapter,
		Class modelType,
		Class jdbcType,
		JavaTypeDescriptor<T> entityAttributeJavaTypeDescriptor) {
	super( sqlTypeDescriptorAdapter, entityAttributeJavaTypeDescriptor );
	this.name = name;
	this.description = description;
	this.modelType = modelType;
	this.jdbcType = jdbcType;
	this.attributeConverter = attributeConverter;

	this.mutabilityPlan = entityAttributeJavaTypeDescriptor.getMutabilityPlan().isMutable()
			? new AttributeConverterMutabilityPlanImpl<T>( attributeConverter )
			: ImmutableMutabilityPlan.INSTANCE;

	log.debug( "Created AttributeConverterTypeAdapter -> " + name );
}
 
Example #2
Source File: DB297Dialect.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected SqlTypeDescriptor getSqlTypeDescriptorOverride(int sqlCode) {
	// 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.
	switch ( sqlCode ) {
		case Types.NCHAR:
			return CharTypeDescriptor.INSTANCE;

		case Types.NCLOB:
			if ( useInputStreamToInsertBlob() ) {
				return ClobTypeDescriptor.STREAM_BINDING;
			}
			else {
				return ClobTypeDescriptor.CLOB_BINDING;
			}

		case Types.NVARCHAR:
			return VarcharTypeDescriptor.INSTANCE;

		default:
			return super.getSqlTypeDescriptorOverride( sqlCode );
	}
}
 
Example #3
Source File: AbstractHANADialect.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected SqlTypeDescriptor getSqlTypeDescriptorOverride(final int sqlCode) {
	switch ( sqlCode ) {
		case Types.CLOB:
			return this.clobTypeDescriptor;
		case Types.NCLOB:
			return this.nClobTypeDescriptor;
		case Types.BLOB:
			return this.blobTypeDescriptor;
		case Types.TINYINT:
			// tinyint is unsigned on HANA
			return SmallIntTypeDescriptor.INSTANCE;
		case Types.BOOLEAN:
			return this.useLegacyBooleanType ? BitTypeDescriptor.INSTANCE : BooleanTypeDescriptor.INSTANCE;
		case Types.VARCHAR:
			return this.useUnicodeStringTypes ? NVarcharTypeDescriptor.INSTANCE : VarcharTypeDescriptor.INSTANCE;
		case Types.CHAR:
			return this.useUnicodeStringTypes ? NCharTypeDescriptor.INSTANCE : CharTypeDescriptor.INSTANCE;
		default:
			return super.getSqlTypeDescriptorOverride( sqlCode );
	}
}
 
Example #4
Source File: PostgreSQL81Dialect.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
@Override
public SqlTypeDescriptor getSqlTypeDescriptorOverride(int sqlCode) {
	SqlTypeDescriptor descriptor;
	switch ( sqlCode ) {
		case Types.BLOB: {
			// 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.
			descriptor = BlobTypeDescriptor.BLOB_BINDING;
			break;
		}
		case Types.CLOB: {
			descriptor = ClobTypeDescriptor.CLOB_BINDING;
			break;
		}
		default: {
			descriptor = super.getSqlTypeDescriptorOverride( sqlCode );
			break;
		}
	}
	return descriptor;
}
 
Example #5
Source File: StandardBasicTypeTemplate.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public StandardBasicTypeTemplate(
		SqlTypeDescriptor sqlTypeDescriptor,
		JavaTypeDescriptor<J> javaTypeDescriptor,
		String... registrationKeys) {
	super( sqlTypeDescriptor, javaTypeDescriptor );
	this.registrationKeys = registrationKeys;

	this.name = javaTypeDescriptor.getJavaType() == null ? "(map-mode)" : javaTypeDescriptor.getJavaType().getName()
			+ " -> " + sqlTypeDescriptor.getSqlType();
}
 
Example #6
Source File: FixedPostgreSQL95Dialect.java    From jhipster with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public SqlTypeDescriptor remapSqlTypeDescriptor(SqlTypeDescriptor sqlTypeDescriptor) {
    if (sqlTypeDescriptor.getSqlType() == java.sql.Types.BLOB) {
        return BinaryTypeDescriptor.INSTANCE;
    }
    return super.remapSqlTypeDescriptor(sqlTypeDescriptor);
}
 
Example #7
Source File: FixedPostgreSQL82Dialect.java    From jhipster with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public SqlTypeDescriptor remapSqlTypeDescriptor(SqlTypeDescriptor sqlTypeDescriptor) {
    if (sqlTypeDescriptor.getSqlType() == java.sql.Types.BLOB) {
        return BinaryTypeDescriptor.INSTANCE;
    }
    return super.remapSqlTypeDescriptor(sqlTypeDescriptor);
}
 
Example #8
Source File: AttributeConverterSqlTypeDescriptorAdapter.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public AttributeConverterSqlTypeDescriptorAdapter(
		JpaAttributeConverter converter,
		SqlTypeDescriptor delegate,
		JavaTypeDescriptor intermediateJavaTypeDescriptor) {
	this.converter = converter;
	this.delegate = delegate;
	this.intermediateJavaTypeDescriptor = intermediateJavaTypeDescriptor;
}
 
Example #9
Source File: FixedPostgreSQL10Dialect.java    From jhipster with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public SqlTypeDescriptor remapSqlTypeDescriptor(SqlTypeDescriptor sqlTypeDescriptor) {
    if (sqlTypeDescriptor.getSqlType() == java.sql.Types.BLOB) {
        return BinaryTypeDescriptor.INSTANCE;
    }
    return super.remapSqlTypeDescriptor(sqlTypeDescriptor);
}
 
Example #10
Source File: FixedPostgreSQL82Dialect.java    From jhipster-ribbon-hystrix with GNU General Public License v3.0 5 votes vote down vote up
@Override
public SqlTypeDescriptor remapSqlTypeDescriptor(SqlTypeDescriptor sqlTypeDescriptor) {
    if (sqlTypeDescriptor.getSqlType() == java.sql.Types.BLOB) {
        return BinaryTypeDescriptor.INSTANCE;
    }
    return super.remapSqlTypeDescriptor(sqlTypeDescriptor);
}
 
Example #11
Source File: _FixedPostgreSQL82Dialect.java    From jhipster-ribbon-hystrix with GNU General Public License v3.0 5 votes vote down vote up
@Override
public SqlTypeDescriptor remapSqlTypeDescriptor(SqlTypeDescriptor sqlTypeDescriptor) {
    if (sqlTypeDescriptor.getSqlType() == java.sql.Types.BLOB) {
        return BinaryTypeDescriptor.INSTANCE;
    }
    return super.remapSqlTypeDescriptor(sqlTypeDescriptor);
}
 
Example #12
Source File: Dialect.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the {@link SqlTypeDescriptor} that should be used to handle the given JDBC type code.  Returns
 * {@code null} if there is no override.
 *
 * @param sqlCode A {@link Types} constant indicating the SQL column type
 * @return The {@link SqlTypeDescriptor} to use as an override, or {@code null} if there is no override.
 */
protected SqlTypeDescriptor getSqlTypeDescriptorOverride(int sqlCode) {
	SqlTypeDescriptor descriptor;
	switch ( sqlCode ) {
		case Types.CLOB: {
			descriptor = useInputStreamToInsertBlob() ? ClobTypeDescriptor.STREAM_BINDING : null;
			break;
		}
		default: {
			descriptor = null;
			break;
		}
	}
	return descriptor;
}
 
Example #13
Source File: PostgreSQLDialect.java    From onedev with MIT License 5 votes vote down vote up
@Override
public SqlTypeDescriptor remapSqlTypeDescriptor(SqlTypeDescriptor sqlTypeDescriptor) {
	if (sqlTypeDescriptor.getSqlType() == java.sql.Types.BLOB) {
		return BinaryTypeDescriptor.INSTANCE;
	}
	return super.remapSqlTypeDescriptor(sqlTypeDescriptor);
}
 
Example #14
Source File: FixedPostgreSQL82Dialect.java    From klask-io with GNU General Public License v3.0 5 votes vote down vote up
@Override
public SqlTypeDescriptor remapSqlTypeDescriptor(SqlTypeDescriptor sqlTypeDescriptor) {
    if (sqlTypeDescriptor.getSqlType() == java.sql.Types.BLOB) {
        return BinaryTypeDescriptor.INSTANCE;
    }
    return super.remapSqlTypeDescriptor(sqlTypeDescriptor);
}
 
Example #15
Source File: FixedPostgreSQL82Dialect.java    From ServiceCutter with Apache License 2.0 5 votes vote down vote up
@Override
public SqlTypeDescriptor remapSqlTypeDescriptor(SqlTypeDescriptor sqlTypeDescriptor) {
    if (sqlTypeDescriptor.getSqlType() == java.sql.Types.BLOB) {
        return BinaryTypeDescriptor.INSTANCE;
    }
    return super.remapSqlTypeDescriptor(sqlTypeDescriptor);
}
 
Example #16
Source File: SybaseDialect.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected SqlTypeDescriptor getSqlTypeDescriptorOverride(int sqlCode) {
	switch (sqlCode) {
	case Types.BLOB:
		return BlobTypeDescriptor.PRIMITIVE_ARRAY_BINDING;
	case Types.CLOB:
		// Some Sybase drivers cannot support getClob.  See HHH-7889
		return ClobTypeDescriptor.STREAM_BINDING_EXTRACTING;
	default:
		return super.getSqlTypeDescriptorOverride( sqlCode );
	}
}
 
Example #17
Source File: DB2Dialect.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected SqlTypeDescriptor getSqlTypeDescriptorOverride(int sqlCode) {
	if ( sqlCode == Types.BOOLEAN ) {
		return SmallIntTypeDescriptor.INSTANCE;
	}
	else if ( sqlCode == Types.NUMERIC ) {
		return DecimalTypeDescriptor.INSTANCE;
	}

	return super.getSqlTypeDescriptorOverride( sqlCode );
}
 
Example #18
Source File: FixedPostgreSQL82Dialect.java    From expper with GNU General Public License v3.0 5 votes vote down vote up
@Override
public SqlTypeDescriptor remapSqlTypeDescriptor(SqlTypeDescriptor sqlTypeDescriptor) {
    if (sqlTypeDescriptor.getSqlType() == java.sql.Types.BLOB) {
        return BinaryTypeDescriptor.INSTANCE;
    }
    return super.remapSqlTypeDescriptor(sqlTypeDescriptor);
}
 
Example #19
Source File: FixedPostgreSQL82Dialect.java    From jhipster-ribbon-hystrix with GNU General Public License v3.0 5 votes vote down vote up
@Override
public SqlTypeDescriptor remapSqlTypeDescriptor(SqlTypeDescriptor sqlTypeDescriptor) {
    if (sqlTypeDescriptor.getSqlType() == java.sql.Types.BLOB) {
        return BinaryTypeDescriptor.INSTANCE;
    }
    return super.remapSqlTypeDescriptor(sqlTypeDescriptor);
}
 
Example #20
Source File: AbstractSharedSessionContract.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public SqlTypeDescriptor remapSqlTypeDescriptor(SqlTypeDescriptor sqlTypeDescriptor) {
	if ( !sqlTypeDescriptor.canBeRemapped() ) {
		return sqlTypeDescriptor;
	}

	final Dialect dialect = getJdbcServices().getJdbcEnvironment().getDialect();
	final SqlTypeDescriptor remapped = dialect.remapSqlTypeDescriptor( sqlTypeDescriptor );
	return remapped == null ? sqlTypeDescriptor : remapped;
}
 
Example #21
Source File: FixedPostgreSQL82Dialect.java    From jhipster-ribbon-hystrix with GNU General Public License v3.0 5 votes vote down vote up
@Override
public SqlTypeDescriptor remapSqlTypeDescriptor(SqlTypeDescriptor sqlTypeDescriptor) {
    if (sqlTypeDescriptor.getSqlType() == java.sql.Types.BLOB) {
        return BinaryTypeDescriptor.INSTANCE;
    }
    return super.remapSqlTypeDescriptor(sqlTypeDescriptor);
}
 
Example #22
Source File: FixedPostgreSQL82DialectTest.java    From jhipster with Apache License 2.0 4 votes vote down vote up
@Test
public void testOtherTypeRemap() {
    SqlTypeDescriptor descriptor = dialect.remapSqlTypeDescriptor(BooleanTypeDescriptor.INSTANCE);
    assertThat(descriptor).isEqualTo(BooleanTypeDescriptor.INSTANCE);
}
 
Example #23
Source File: FixedPostgreSQL10DialectTest.java    From jhipster with Apache License 2.0 4 votes vote down vote up
@Test
public void testBlobTypeRemap() {
    SqlTypeDescriptor descriptor = dialect.remapSqlTypeDescriptor(BlobTypeDescriptor.DEFAULT);
    assertThat(descriptor).isEqualTo(BinaryTypeDescriptor.INSTANCE);
}
 
Example #24
Source File: FixedPostgreSQL10DialectTest.java    From jhipster with Apache License 2.0 4 votes vote down vote up
@Test
public void testOtherTypeRemap() {
    SqlTypeDescriptor descriptor = dialect.remapSqlTypeDescriptor(BooleanTypeDescriptor.INSTANCE);
    assertThat(descriptor).isEqualTo(BooleanTypeDescriptor.INSTANCE);
}
 
Example #25
Source File: FixedPostgreSQL82DialectTest.java    From jhipster with Apache License 2.0 4 votes vote down vote up
@Test
public void testBlobTypeRemap() {
    SqlTypeDescriptor descriptor = dialect.remapSqlTypeDescriptor(BlobTypeDescriptor.DEFAULT);
    assertThat(descriptor).isEqualTo(BinaryTypeDescriptor.INSTANCE);
}
 
Example #26
Source File: SqlTypeDescriptorRegistry.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public SqlTypeDescriptor getDescriptor(int jdbcTypeCode) {
	return sqlTypeDescriptorRegistry.getDescriptor( jdbcTypeCode );
}
 
Example #27
Source File: FixedPostgreSQL95DialectTest.java    From jhipster with Apache License 2.0 4 votes vote down vote up
@Test
public void testBlobTypeRemap() {
    SqlTypeDescriptor descriptor = dialect.remapSqlTypeDescriptor(BlobTypeDescriptor.DEFAULT);
    assertThat(descriptor).isEqualTo(BinaryTypeDescriptor.INSTANCE);
}
 
Example #28
Source File: FixedPostgreSQL95DialectTest.java    From jhipster with Apache License 2.0 4 votes vote down vote up
@Test
public void testOtherTypeRemap() {
    SqlTypeDescriptor descriptor = dialect.remapSqlTypeDescriptor(BooleanTypeDescriptor.INSTANCE);
    assertThat(descriptor).isEqualTo(BooleanTypeDescriptor.INSTANCE);
}
 
Example #29
Source File: StringCollectionDescriptor.java    From nomulus with Apache License 2.0 4 votes vote down vote up
@Override
public SqlTypeDescriptor getJdbcRecommendedSqlType(JdbcRecommendedSqlTypeMappingContext context) {
  return this;
}
 
Example #30
Source File: StringMapDescriptor.java    From nomulus with Apache License 2.0 4 votes vote down vote up
@Override
public SqlTypeDescriptor getJdbcRecommendedSqlType(JdbcRecommendedSqlTypeMappingContext context) {
  return this;
}