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

The following examples show how to use org.hibernate.type.descriptor.sql.SqlTypeDescriptor. These examples are extracted from open source projects. 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 Project: lams   Source File: DB297Dialect.java    License: 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 2
Source Project: lams   Source File: AbstractHANADialect.java    License: 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 3
Source Project: lams   Source File: PostgreSQL81Dialect.java    License: 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 4
@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 5
Source Project: onedev   Source File: PostgreSQLDialect.java    License: 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 6
@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 7
Source Project: lams   Source File: DB2Dialect.java    License: 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 8
Source Project: lams   Source File: SybaseDialect.java    License: 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 9
Source Project: lams   Source File: Dialect.java    License: 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 10
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 11
public AttributeConverterSqlTypeDescriptorAdapter(
		JpaAttributeConverter converter,
		SqlTypeDescriptor delegate,
		JavaTypeDescriptor intermediateJavaTypeDescriptor) {
	this.converter = converter;
	this.delegate = delegate;
	this.intermediateJavaTypeDescriptor = intermediateJavaTypeDescriptor;
}
 
Example 12
@Override
public SqlTypeDescriptor remapSqlTypeDescriptor(SqlTypeDescriptor sqlTypeDescriptor) {
    if (sqlTypeDescriptor.getSqlType() == java.sql.Types.BLOB) {
        return BinaryTypeDescriptor.INSTANCE;
    }
    return super.remapSqlTypeDescriptor(sqlTypeDescriptor);
}
 
Example 13
@Override
public SqlTypeDescriptor remapSqlTypeDescriptor(SqlTypeDescriptor sqlTypeDescriptor) {
    if (sqlTypeDescriptor.getSqlType() == java.sql.Types.BLOB) {
        return BinaryTypeDescriptor.INSTANCE;
    }
    return super.remapSqlTypeDescriptor(sqlTypeDescriptor);
}
 
Example 14
@Override
public SqlTypeDescriptor remapSqlTypeDescriptor(SqlTypeDescriptor sqlTypeDescriptor) {
    if (sqlTypeDescriptor.getSqlType() == java.sql.Types.BLOB) {
        return BinaryTypeDescriptor.INSTANCE;
    }
    return super.remapSqlTypeDescriptor(sqlTypeDescriptor);
}
 
Example 15
@Override
public SqlTypeDescriptor remapSqlTypeDescriptor(SqlTypeDescriptor sqlTypeDescriptor) {
    if (sqlTypeDescriptor.getSqlType() == java.sql.Types.BLOB) {
        return BinaryTypeDescriptor.INSTANCE;
    }
    return super.remapSqlTypeDescriptor(sqlTypeDescriptor);
}
 
Example 16
@Override
public SqlTypeDescriptor remapSqlTypeDescriptor(SqlTypeDescriptor sqlTypeDescriptor) {
    if (sqlTypeDescriptor.getSqlType() == java.sql.Types.BLOB) {
        return BinaryTypeDescriptor.INSTANCE;
    }
    return super.remapSqlTypeDescriptor(sqlTypeDescriptor);
}
 
Example 17
Source Project: jhipster   Source File: FixedPostgreSQL10Dialect.java    License: 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 18
Source Project: jhipster   Source File: FixedPostgreSQL82Dialect.java    License: 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 19
Source Project: jhipster   Source File: FixedPostgreSQL95Dialect.java    License: 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 20
Source Project: ServiceCutter   Source File: FixedPostgreSQL82Dialect.java    License: 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 21
@Override
public SqlTypeDescriptor remapSqlTypeDescriptor(SqlTypeDescriptor sqlTypeDescriptor) {
    if (sqlTypeDescriptor.getSqlType() == java.sql.Types.BLOB) {
        return BinaryTypeDescriptor.INSTANCE;
    }
    return super.remapSqlTypeDescriptor(sqlTypeDescriptor);
}
 
Example 22
@Override
public SqlTypeDescriptor remapSqlTypeDescriptor(SqlTypeDescriptor sqlTypeDescriptor) {
	return delegate.remapSqlTypeDescriptor( sqlTypeDescriptor );
}
 
Example 23
Source Project: lams   Source File: SybaseASE15Dialect.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Override
protected SqlTypeDescriptor getSqlTypeDescriptorOverride(int sqlCode) {
	return sqlCode == Types.BOOLEAN ? TinyIntTypeDescriptor.INSTANCE : super.getSqlTypeDescriptorOverride( sqlCode );
}
 
Example 24
Source Project: lams   Source File: Oracle8iDialect.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Override
protected SqlTypeDescriptor getSqlTypeDescriptorOverride(int sqlCode) {
	return sqlCode == Types.BOOLEAN ? BitTypeDescriptor.INSTANCE : super.getSqlTypeDescriptorOverride( sqlCode );
}
 
Example 25
Source Project: lams   Source File: AbstractHANADialect.java    License: GNU General Public License v2.0 4 votes vote down vote up
public SqlTypeDescriptor getBlobTypeDescriptor() {
	return this.blobTypeDescriptor;
}
 
Example 26
Source Project: lams   Source File: SQLServerDialect.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Override
protected SqlTypeDescriptor getSqlTypeDescriptorOverride(int sqlCode) {
	return sqlCode == Types.TINYINT ?
			SmallIntTypeDescriptor.INSTANCE :
			super.getSqlTypeDescriptorOverride( sqlCode );
}
 
Example 27
Source Project: lams   Source File: MetadataBuilderImpl.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Override
public void contributeSqlTypeDescriptor(SqlTypeDescriptor descriptor) {
	this.bootstrapContext.getTypeConfiguration().getSqlTypeDescriptorRegistry().addDescriptor( descriptor );
}
 
Example 28
public AbstractSingleColumnStandardBasicType(SqlTypeDescriptor sqlTypeDescriptor, JavaTypeDescriptor<T> javaTypeDescriptor) {
	super( sqlTypeDescriptor, javaTypeDescriptor );
}
 
Example 29
public AbstractStandardBasicType(SqlTypeDescriptor sqlTypeDescriptor, JavaTypeDescriptor<T> javaTypeDescriptor) {
	this.sqlTypeDescriptor = sqlTypeDescriptor;
	this.sqlTypes = new int[] { sqlTypeDescriptor.getSqlType() };
	this.javaTypeDescriptor = javaTypeDescriptor;
}
 
Example 30
public final SqlTypeDescriptor getSqlTypeDescriptor() {
	return sqlTypeDescriptor;
}