@Override protected SqlTypeDescriptor getSqlTypeDescriptorOverride(final int sqlCode) { switch ( sqlCode ) { case Types.BOOLEAN: return BitTypeDescriptor.INSTANCE; case Types.CLOB: return HANA_CLOB_STREAM_BINDING; case Types.NCLOB: return HANA_NCLOB_STREAM_BINDING; case Types.TINYINT: // tinyint is unsigned on HANA return SmallIntTypeDescriptor.INSTANCE; default: return super.getSqlTypeDescriptorOverride( sqlCode ); } }
@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; }
private WrapperOptions getOptions(final SessionImplementor session) { return new WrapperOptions() { public boolean useStreamForLobBinding() { return Environment.useStreamsForBinary() || session.getFactory().getDialect().useInputStreamToInsertBlob(); } public LobCreator getLobCreator() { return Hibernate.getLobCreator( session ); } public SqlTypeDescriptor remapSqlTypeDescriptor(SqlTypeDescriptor sqlTypeDescriptor) { final SqlTypeDescriptor remapped = sqlTypeDescriptor.canBeRemapped() ? session.getFactory().getDialect().remapSqlTypeDescriptor( sqlTypeDescriptor ) : sqlTypeDescriptor; return remapped == null ? sqlTypeDescriptor : remapped; } }; }
public <X> ValueBinder<X> getBinder(final JavaTypeDescriptor<X> javaTypeDescriptor) { return new BasicBinder<X>(javaTypeDescriptor, (SqlTypeDescriptor) this) { @Override protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException { if (cal == null) { st.setDate(index, javaTypeDescriptor.unwrap(value, Date.class, options)); } else { st.setDate(index, javaTypeDescriptor.unwrap(value, Date.class, options), cal); } } }; }
@Override public SqlTypeDescriptor remapSqlTypeDescriptor(SqlTypeDescriptor sqlTypeDescriptor) { if (sqlTypeDescriptor.getSqlType() == java.sql.Types.BLOB) { return BinaryTypeDescriptor.INSTANCE; } return super.remapSqlTypeDescriptor(sqlTypeDescriptor); }
@Override public SqlTypeDescriptor remapSqlTypeDescriptor(SqlTypeDescriptor sqlTypeDescriptor) { if (Types.CLOB == sqlTypeDescriptor.getSqlType()) { return LongVarcharTypeDescriptor.INSTANCE; } return super.remapSqlTypeDescriptor(sqlTypeDescriptor); }
@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 ); } }
/** * 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; }
public AttributeConverterTypeAdapter( String name, AttributeConverter<? extends T,?> attributeConverter, SqlTypeDescriptor sqlTypeDescriptorAdapter, Class modelType, Class jdbcType, JavaTypeDescriptor<T> entityAttributeJavaTypeDescriptor) { super( sqlTypeDescriptorAdapter, entityAttributeJavaTypeDescriptor ); this.name = name; this.modelType = modelType; this.jdbcType = jdbcType; this.attributeConverter = attributeConverter; log.debug( "Created AttributeConverterTypeAdapter -> " + name ); }
public AttributeConverterSqlTypeDescriptorAdapter( AttributeConverter converter, SqlTypeDescriptor delegate, JavaTypeDescriptor intermediateJavaTypeDescriptor) { this.converter = converter; this.delegate = delegate; this.intermediateJavaTypeDescriptor = intermediateJavaTypeDescriptor; }
@Override public SqlTypeDescriptor getSqlTypeDescriptorOverride(int sqlCode) { if (Types.BLOB == sqlCode) { return LongVarbinaryTypeDescriptor.INSTANCE; } return super.getSqlTypeDescriptorOverride(sqlCode); }
public <X> ValueExtractor<X> getExtractor( final JavaTypeDescriptor<X> javaTypeDescriptor) { return new BasicExtractor<X>(javaTypeDescriptor, (SqlTypeDescriptor) this) { @Override protected X doExtract(ResultSet rs, String name, WrapperOptions options) throws SQLException { if (cal == null) { return javaTypeDescriptor.wrap(rs.getDate(name), options); } else { return javaTypeDescriptor.wrap(rs.getDate(name, cal), options); } } }; }
@Override public SqlTypeDescriptor remapSqlTypeDescriptor(SqlTypeDescriptor sqlTypeDescriptor) { if (sqlTypeDescriptor.getSqlType() == java.sql.Types.BLOB) return BinaryTypeDescriptor.INSTANCE; else return super.remapSqlTypeDescriptor(sqlTypeDescriptor); }
@Override protected SqlTypeDescriptor getSqlTypeDescriptorOverride(int sqlCode) { return sqlCode == Types.BOOLEAN ? TinyIntTypeDescriptor.INSTANCE : super.getSqlTypeDescriptorOverride( sqlCode ); }
@Override protected SqlTypeDescriptor getSqlTypeDescriptorOverride(int sqlCode) { return sqlCode == Types.BOOLEAN ? BitTypeDescriptor.INSTANCE : super.getSqlTypeDescriptorOverride( sqlCode ); }
@Override protected SqlTypeDescriptor getSqlTypeDescriptorOverride(int sqlCode) { return sqlCode == Types.BOOLEAN ? SmallIntTypeDescriptor.INSTANCE : super.getSqlTypeDescriptorOverride( sqlCode ); }
@Override protected SqlTypeDescriptor getSqlTypeDescriptorOverride(int sqlCode) { return sqlCode == Types.TINYINT ? SmallIntTypeDescriptor.INSTANCE : super.getSqlTypeDescriptorOverride( sqlCode ); }
public AbstractSingleColumnStandardBasicType(SqlTypeDescriptor sqlTypeDescriptor, JavaTypeDescriptor<T> javaTypeDescriptor) { super( sqlTypeDescriptor, javaTypeDescriptor ); }
public AbstractStandardBasicType(SqlTypeDescriptor sqlTypeDescriptor, JavaTypeDescriptor<T> javaTypeDescriptor) { this.sqlTypeDescriptor = sqlTypeDescriptor; this.sqlTypes = new int[] { sqlTypeDescriptor.getSqlType() }; this.javaTypeDescriptor = javaTypeDescriptor; }
public final SqlTypeDescriptor getSqlTypeDescriptor() { return sqlTypeDescriptor; }
public final void setSqlTypeDescriptor( SqlTypeDescriptor sqlTypeDescriptor ) { this.sqlTypeDescriptor = sqlTypeDescriptor; this.sqlTypes = new int[] { sqlTypeDescriptor.getSqlType() }; }
protected SqlTypeDescriptor remapSqlTypeDescriptor(WrapperOptions options) { return options.remapSqlTypeDescriptor( sqlTypeDescriptor ); }
protected BooleanType(SqlTypeDescriptor sqlTypeDescriptor, BooleanTypeDescriptor javaTypeDescriptor) { super( sqlTypeDescriptor, javaTypeDescriptor ); }
@Override public SqlTypeDescriptor remapSqlTypeDescriptor(SqlTypeDescriptor sqlTypeDescriptor) { return sqlTypeDescriptor.getSqlType() == BLOB ? BinaryTypeDescriptor.INSTANCE : super.remapSqlTypeDescriptor(sqlTypeDescriptor); }
@Override public SqlTypeDescriptor remapSqlTypeDescriptor(final SqlTypeDescriptor sqlTypeDescriptor) { return this.wrapped.remapSqlTypeDescriptor(sqlTypeDescriptor); }