Java 类org.hibernate.type.descriptor.WrapperOptions 实例源码

项目:hibernate-ogm-redis    文件:Base64ByteArrayTypeDescriptor.java   
@Override
@SuppressWarnings( {"unchecked" } )
public <X> X unwrap(byte[] value, Class<X> type, WrapperOptions options) {
    if ( value == null ) {
        return null;
    }
    if ( Byte[].class.isAssignableFrom( type ) ) {
        return (X) value;
    }
    if ( byte[].class.isAssignableFrom( type ) ) {
        return (X) value;
    }
    if ( InputStream.class.isAssignableFrom( type ) ) {
        return (X) new ByteArrayInputStream( value );
    }
    if ( BinaryStream.class.isAssignableFrom( type ) ) {
        return (X) new BinaryStreamImpl( value );
    }
    if ( Blob.class.isAssignableFrom( type ) ) {
        return (X) options.getLobCreator().createBlob( value );
    }

    throw unknownUnwrap( type );
}
项目:hibernate-ogm-redis    文件:Base64ByteArrayTypeDescriptor.java   
@Override
public <X> byte[] wrap(X value, WrapperOptions options) {
    if ( value == null ) {
        return null;
    }
    if ( Byte[].class.isInstance( value ) ) {
        return unwrapBytes( (Byte[]) value );
    }
    if ( byte[].class.isInstance( value ) ) {
        return (byte[]) value;
    }
    if ( InputStream.class.isInstance( value ) ) {
        return DataHelper.extractBytes( (InputStream) value );
    }
    if ( Blob.class.isInstance( value ) || DataHelper.isNClob( value.getClass() ) ) {
        try {
            return DataHelper.extractBytes( ( (Blob) value ).getBinaryStream() );
        }
        catch (SQLException e) {
            throw new HibernateException( "Unable to access lob stream", e );
        }
    }

    throw unknownWrap( value.getClass() );
}
项目:lams    文件:AbstractHANADialect.java   
@Override
public <X> BasicBinder<X> getClobBinder(final JavaTypeDescriptor<X> javaTypeDescriptor) {
    return new BasicBinder<X>( javaTypeDescriptor, this ) {
        @Override
        protected void doBind(final PreparedStatement st, final X value, final int index,
                final WrapperOptions options) throws SQLException {
            final CharacterStream characterStream = javaTypeDescriptor.unwrap( value, CharacterStream.class,
                    options );

            if ( value instanceof ClobImplementer ) {
                st.setCharacterStream( index, new CloseSuppressingReader( characterStream.asReader() ),
                        characterStream.getLength() );
            }
            else {
                st.setCharacterStream( index, characterStream.asReader(), characterStream.getLength() );
            }

        }
    };
}
项目:lams    文件:AttributeConverterSqlTypeDescriptorAdapter.java   
@Override
@SuppressWarnings("unchecked")
public <X> ValueBinder<X> getBinder(JavaTypeDescriptor<X> javaTypeDescriptor) {
    // Get the binder for the intermediate type representation
    final ValueBinder realBinder = delegate.getBinder( intermediateJavaTypeDescriptor );
    return new BasicBinder<X>( javaTypeDescriptor, this ) {
        @Override
        @SuppressWarnings("unchecked")
        protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException {
            final Object convertedValue;
            try {
                convertedValue = converter.convertToDatabaseColumn( value );
            }
            catch (PersistenceException pe) {
                throw pe;
            }
            catch (RuntimeException re) {
                throw new PersistenceException( "Error attempting to apply AttributeConverter", re );
            }
            realBinder.bind( st, convertedValue, index, options );
        }
    };
}
项目:lams    文件:ClobTypeDescriptor.java   
public <X> Clob wrap(X value, WrapperOptions options) {
    if ( value == null ) {
        return null;
    }

    // Support multiple return types from
    // org.hibernate.type.descriptor.sql.ClobTypeDescriptor
    if ( Clob.class.isAssignableFrom( value.getClass() ) ) {
        return options.getLobCreator().wrap( (Clob) value );
    }
    else if ( Reader.class.isAssignableFrom( value.getClass() ) ) {
        Reader reader = (Reader) value;
        return options.getLobCreator().createClob( DataHelper.extractString( reader ) );
    }

    throw unknownWrap( value.getClass() );
}
项目:lams    文件:BooleanTypeDescriptor.java   
@Override
public <X> Boolean wrap(X value, WrapperOptions options) {
    if ( value == null ) {
        return null;
    }
    if ( Boolean.class.isInstance( value ) ) {
        return (Boolean) value;
    }
    if ( Number.class.isInstance( value ) ) {
        final int intValue = ( (Number) value ).intValue();
        return intValue == 0 ? FALSE : TRUE;
    }
    if ( Character.class.isInstance( value ) ) {
        return isTrue( (Character) value ) ? TRUE : FALSE;
    }
    if ( String.class.isInstance( value ) ) {
        return isTrue( ( (String) value ).charAt( 0 ) ) ? TRUE : FALSE;
    }
    throw unknownWrap( value.getClass() );
}
项目:lams    文件:ShortTypeDescriptor.java   
@Override
public <X> Short wrap(X value, WrapperOptions options) {
    if ( value == null ) {
        return null;
    }
    if ( Short.class.isInstance( value ) ) {
        return (Short) value;
    }
    if ( Number.class.isInstance( value ) ) {
        return ( (Number) value ).shortValue();
    }
    if ( String.class.isInstance( value ) ) {
        return Short.valueOf( ( (String) value ) );
    }
    throw unknownWrap( value.getClass() );
}
项目:lams    文件:NClobTypeDescriptor.java   
public <X> NClob wrap(X value, WrapperOptions options) {
    if ( value == null ) {
        return null;
    }

    // Support multiple return types from
    // org.hibernate.type.descriptor.sql.ClobTypeDescriptor
    if ( NClob.class.isAssignableFrom( value.getClass() ) ) {
        return options.getLobCreator().wrap( (NClob) value );
    }
    else if ( Reader.class.isAssignableFrom( value.getClass() ) ) {
        Reader reader = (Reader) value;
        return options.getLobCreator().createNClob( DataHelper.extractString( reader ) );
    }

    throw unknownWrap( value.getClass() );
}
项目:lams    文件:JdbcDateTypeDescriptor.java   
@Override
public <X> Date wrap(X value, WrapperOptions options) {
    if ( value == null ) {
        return null;
    }
    if ( Date.class.isInstance( value ) ) {
        return (Date) value;
    }

    if ( Long.class.isInstance( value ) ) {
        return new java.sql.Date( ( (Long) value ).longValue() );
    }

    if ( Calendar.class.isInstance( value ) ) {
        return new java.sql.Date( ( (Calendar) value ).getTimeInMillis() );
    }

    if ( java.util.Date.class.isInstance( value ) ) {
        return new java.sql.Date( ( (java.util.Date) value ).getTime() );
    }

    throw unknownWrap( value.getClass() );
}
项目:lams    文件:CalendarDateTypeDescriptor.java   
@SuppressWarnings({ "unchecked" })
public <X> X unwrap(Calendar value, Class<X> type, WrapperOptions options) {
    if ( value == null ) {
        return null;
    }
    if ( Calendar.class.isAssignableFrom( type ) ) {
        return (X) value;
    }
    if ( java.sql.Date.class.isAssignableFrom( type ) ) {
        return (X) new java.sql.Date( value.getTimeInMillis() );
    }
    if ( java.sql.Time.class.isAssignableFrom( type ) ) {
        return (X) new java.sql.Time( value.getTimeInMillis() );
    }
    if ( java.sql.Timestamp.class.isAssignableFrom( type ) ) {
        return (X) new java.sql.Timestamp( value.getTimeInMillis() );
    }
    if ( Date.class.isAssignableFrom( type ) ) {
        return (X) new  Date( value.getTimeInMillis() );
    }
    throw unknownUnwrap( type );
}
项目:lams    文件:CalendarDateTypeDescriptor.java   
public <X> Calendar wrap(X value, WrapperOptions options) {
    if ( value == null ) {
        return null;
    }
    if ( Calendar.class.isInstance( value ) ) {
        return (Calendar) value;
    }

    if ( ! Date.class.isInstance( value ) ) {
        throw unknownWrap( value.getClass() );
    }

    Calendar cal = new GregorianCalendar();
    if ( Environment.jvmHasTimestampBug() ) {
        final long milliseconds = ( (Date) value ).getTime();
        final long nanoseconds = java.sql.Timestamp.class.isInstance( value )
                ? ( (java.sql.Timestamp) value ).getNanos()
                : 0;
        cal.setTime( new Date( milliseconds + nanoseconds / 1000000 ) );
    }
    else {
        cal.setTime( (Date) value );
    }
    return cal;
}
项目:lams    文件:CharacterTypeDescriptor.java   
@SuppressWarnings({ "unchecked" })
@Override
public <X> X unwrap(Character value, Class<X> type, WrapperOptions options) {
    if ( value == null ) {
        return null;
    }
    if ( Character.class.isAssignableFrom( type ) ) {
        return (X) value;
    }
    if ( String.class.isAssignableFrom( type ) ) {
        return (X) value.toString();
    }
    if ( Number.class.isAssignableFrom( type ) ) {
        return (X) Short.valueOf( (short)value.charValue() );
    }
    throw unknownUnwrap( type );
}
项目:lams    文件:StringTypeDescriptor.java   
@SuppressWarnings({ "unchecked" })
public <X> X unwrap(String value, Class<X> type, WrapperOptions options) {
    if ( value == null ) {
        return null;
    }
    if ( String.class.isAssignableFrom( type ) ) {
        return (X) value;
    }
    if ( Reader.class.isAssignableFrom( type ) ) {
        return (X) new StringReader( value );
    }
    if ( CharacterStream.class.isAssignableFrom( type ) ) {
        return (X) new CharacterStreamImpl( value );
    }
    if ( Clob.class.isAssignableFrom( type ) ) {
        return (X) options.getLobCreator().createClob( value );
    }
    if ( DataHelper.isNClob( type ) ) {
        return (X) options.getLobCreator().createNClob( value );
    }

    throw unknownUnwrap( type );
}
项目:lams    文件:StringTypeDescriptor.java   
public <X> String wrap(X value, WrapperOptions options) {
    if ( value == null ) {
        return null;
    }
    if ( String.class.isInstance( value ) ) {
        return (String) value;
    }
    if ( Reader.class.isInstance( value ) ) {
        return DataHelper.extractString( (Reader) value );
    }
    if ( Clob.class.isInstance( value ) ) {
        return DataHelper.extractString( (Clob) value );
    }

    throw unknownWrap( value.getClass() );
}
项目:lams    文件:UUIDTypeDescriptor.java   
@SuppressWarnings({ "unchecked" })
public <X> X unwrap(UUID value, Class<X> type, WrapperOptions options) {
    if ( value == null ) {
        return null;
    }
    if ( UUID.class.isAssignableFrom( type ) ) {
        return (X) PassThroughTransformer.INSTANCE.transform( value );
    }
    if ( String.class.isAssignableFrom( type ) ) {
        return (X) ToStringTransformer.INSTANCE.transform( value );
    }
    if ( byte[].class.isAssignableFrom( type ) ) {
        return (X) ToBytesTransformer.INSTANCE.transform( value );
    }
    throw unknownUnwrap( type );
}
项目:lams    文件:CalendarTimeTypeDescriptor.java   
@SuppressWarnings({ "unchecked" })
public <X> X unwrap(Calendar value, Class<X> type, WrapperOptions options) {
    if ( value == null ) {
        return null;
    }
    if ( Calendar.class.isAssignableFrom( type ) ) {
        return (X) value;
    }
    if ( java.sql.Date.class.isAssignableFrom( type ) ) {
        return (X) new java.sql.Date( value.getTimeInMillis() );
    }
    if ( java.sql.Time.class.isAssignableFrom( type ) ) {
        return (X) new java.sql.Time( value.getTimeInMillis() );
    }
    if ( java.sql.Timestamp.class.isAssignableFrom( type ) ) {
        return (X) new java.sql.Timestamp( value.getTimeInMillis() );
    }
    if ( Date.class.isAssignableFrom( type ) ) {
        return (X) new  Date( value.getTimeInMillis() );
    }
    throw unknownUnwrap( type );
}
项目:lams    文件:CalendarTimeTypeDescriptor.java   
public <X> Calendar wrap(X value, WrapperOptions options) {
    if ( value == null ) {
        return null;
    }
    if ( Calendar.class.isInstance( value ) ) {
        return (Calendar) value;
    }

    if ( ! Date.class.isInstance( value ) ) {
        throw unknownWrap( value.getClass() );
    }

    Calendar cal = new GregorianCalendar();
    if ( Environment.jvmHasTimestampBug() ) {
        final long milliseconds = ( (Date) value ).getTime();
        final long nanoseconds = java.sql.Timestamp.class.isInstance( value )
                ? ( (java.sql.Timestamp) value ).getNanos()
                : 0;
        cal.setTime( new Date( milliseconds + nanoseconds / 1000000 ) );
    }
    else {
        cal.setTime( (Date) value );
    }
    return cal;
}
项目:lams    文件:CalendarTypeDescriptor.java   
public <X> Calendar wrap(X value, WrapperOptions options) {
    if ( value == null ) {
        return null;
    }
    if ( Calendar.class.isInstance( value ) ) {
        return (Calendar) value;
    }

    if ( ! java.util.Date.class.isInstance( value ) ) {
        throw unknownWrap( value.getClass() );
    }

    Calendar cal = new GregorianCalendar();
    if ( Environment.jvmHasTimestampBug() ) {
        final long milliseconds = ( (java.util.Date) value ).getTime();
        final long nanoseconds = java.sql.Timestamp.class.isInstance( value )
                ? ( (java.sql.Timestamp) value ).getNanos()
                : 0;
        cal.setTime( new Date( milliseconds + nanoseconds / 1000000 ) );
    }
    else {
        cal.setTime( (java.util.Date) value );
    }
    return cal;
}
项目:lams    文件:JdbcTimestampTypeDescriptor.java   
@Override
public <X> Date wrap(X value, WrapperOptions options) {
    if ( value == null ) {
        return null;
    }
    if ( Timestamp.class.isInstance( value ) ) {
        return (Timestamp) value;
    }

    if ( Long.class.isInstance( value ) ) {
        return new Timestamp( (Long) value );
    }

    if ( Calendar.class.isInstance( value ) ) {
        return new Timestamp( ( (Calendar) value ).getTimeInMillis() );
    }

    if ( Date.class.isInstance( value ) ) {
        return (Date) value;
    }

    throw unknownWrap( value.getClass() );
}
项目:lams    文件:BlobTypeDescriptor.java   
@Override
public <X> BasicBinder<X> getBlobBinder(final JavaTypeDescriptor<X> javaTypeDescriptor) {
    return new BasicBinder<X>( javaTypeDescriptor, this ) {
        @Override
        protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options)
                throws SQLException {
            BlobTypeDescriptor descriptor = BLOB_BINDING;
            if ( byte[].class.isInstance( value ) ) {
                // performance shortcut for binding BLOB data in byte[] format
                descriptor = PRIMITIVE_ARRAY_BINDING;
            }
            else if ( options.useStreamForLobBinding() ) {
                descriptor = STREAM_BINDING;
            }
            descriptor.getBlobBinder( javaTypeDescriptor ).doBind( st, value, index, options );
        }
    };
}
项目:lams    文件:ByteTypeDescriptor.java   
@Override
public <X> Byte wrap(X value, WrapperOptions options) {
    if ( value == null ) {
        return null;
    }
    if ( Byte.class.isInstance( value ) ) {
        return (Byte) value;
    }
    if ( Number.class.isInstance( value ) ) {
        return ( (Number) value ).byteValue();
    }
    if ( String.class.isInstance( value ) ) {
        return Byte.valueOf( ( (String) value ) );
    }
    throw unknownWrap( value.getClass() );
}
项目:lams    文件:PrimitiveByteArrayTypeDescriptor.java   
public <X> byte[] wrap(X value, WrapperOptions options) {
    if ( value == null ) {
        return null;
    }
    if ( byte[].class.isInstance( value ) ) {
        return (byte[]) value;
    }
    if ( InputStream.class.isInstance( value ) ) {
        return DataHelper.extractBytes( (InputStream) value );
    }
    if ( Blob.class.isInstance( value ) || DataHelper.isNClob( value.getClass() ) ) {
        try {
            return DataHelper.extractBytes( ( (Blob) value ).getBinaryStream() );
        }
        catch ( SQLException e ) {
            throw new HibernateException( "Unable to access lob stream", e );
        }
    }

    throw unknownWrap( value.getClass() );
}
项目:lams    文件:IntegerTypeDescriptor.java   
@Override
public <X> Integer wrap(X value, WrapperOptions options) {
    if ( value == null ) {
        return null;
    }
    if ( Integer.class.isInstance( value ) ) {
        return (Integer) value;
    }
    if ( Number.class.isInstance( value ) ) {
        return ( (Number) value ).intValue();
    }
    if ( String.class.isInstance( value ) ) {
        return Integer.valueOf( ( (String) value ) );
    }
    throw unknownWrap( value.getClass() );
}
项目:lams    文件:ByteArrayTypeDescriptor.java   
@SuppressWarnings({ "unchecked" })
@Override
public <X> X unwrap(Byte[] value, Class<X> type, WrapperOptions options) {
    if ( value == null ) {
        return null;
    }
    if ( Byte[].class.isAssignableFrom( type ) ) {
        return (X) value;
    }
    if ( byte[].class.isAssignableFrom( type ) ) {
        return (X) unwrapBytes( value );
    }
    if ( InputStream.class.isAssignableFrom( type ) ) {
        return (X) new ByteArrayInputStream( unwrapBytes( value ) );
    }
    if ( BinaryStream.class.isAssignableFrom( type ) ) {
        return (X) new BinaryStreamImpl( unwrapBytes( value ) );
    }
    if ( Blob.class.isAssignableFrom( type ) ) {
        return (X) options.getLobCreator().createBlob( unwrapBytes( value ) );
    }

    throw unknownUnwrap( type );
}
项目:lams    文件:DateTypeDescriptor.java   
@Override
public <X> Date wrap(X value, WrapperOptions options) {
    if ( value == null ) {
        return null;
    }
    if ( Date.class.isInstance( value ) ) {
        return (Date) value;
    }

    if ( Long.class.isInstance( value ) ) {
        return new Date( (Long) value );
    }

    if ( Calendar.class.isInstance( value ) ) {
        return new Date( ( (Calendar) value ).getTimeInMillis() );
    }

    throw unknownWrap( value.getClass() );
}
项目:lams    文件:LongTypeDescriptor.java   
@Override
public <X> Long wrap(X value, WrapperOptions options) {
    if ( value == null ) {
        return null;
    }
    if ( Long.class.isInstance( value ) ) {
        return (Long) value;
    }
    if ( Number.class.isInstance( value ) ) {
        return ( (Number) value ).longValue();
    }
    else if ( String.class.isInstance( value ) ) {
        return Long.valueOf( ( (String) value ) );
    }
    throw unknownWrap( value.getClass() );
}
项目:lams    文件:SerializableTypeDescriptor.java   
@SuppressWarnings({ "unchecked" })
public <X> X unwrap(T value, Class<X> type, WrapperOptions options) {
    if ( value == null ) {
        return null;
    }
    else if ( type.isInstance( value ) ) {
        return (X) value;
    }
    else if ( byte[].class.isAssignableFrom( type ) ) {
        return (X) toBytes( value );
    }
    else if ( InputStream.class.isAssignableFrom( type ) ) {
        return (X) new ByteArrayInputStream( toBytes( value ) );
    }
    else if ( BinaryStream.class.isAssignableFrom( type ) ) {
        return (X) new BinaryStreamImpl( toBytes( value ) );
    }
    else if ( Blob.class.isAssignableFrom( type )) {
        return (X) options.getLobCreator().createBlob( toBytes(value) );
    }

    throw unknownUnwrap( type );
}
项目:lams    文件:PrimitiveCharacterArrayTypeDescriptor.java   
@SuppressWarnings({ "unchecked" })
public <X> X unwrap(char[] value, Class<X> type, WrapperOptions options) {
    if ( value == null ) {
        return null;
    }
    if ( char[].class.isAssignableFrom( type ) ) {
        return (X) value;
    }
    if ( String.class.isAssignableFrom( type ) ) {
        return (X) new String( value );
    }
    if ( Clob.class.isAssignableFrom( type ) ) {
        return (X) options.getLobCreator().createClob( new String( value ) );
    }
    if ( Reader.class.isAssignableFrom( type ) ) {
        return (X) new StringReader( new String( value ) );
    }
    if ( CharacterStream.class.isAssignableFrom( type ) ) {
        return (X) new CharacterStreamImpl( new String( value ) );
    }
    throw unknownUnwrap( type );
}
项目:lams    文件:ClobTypeDescriptor.java   
@Override
            public <X> BasicBinder<X> getClobBinder(final JavaTypeDescriptor<X> javaTypeDescriptor) {
    return new BasicBinder<X>( javaTypeDescriptor, this ) {
        @Override
        protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options)
                throws SQLException {
            st.setClob( index, javaTypeDescriptor.unwrap( value, Clob.class, options ) );
        }
    };
}
项目:lams    文件:BasicExtractor.java   
@Override
public J extract(ResultSet rs, String name, WrapperOptions options) throws SQLException {
    final J value = doExtract( rs, name, options );
    final boolean traceEnabled = log.isTraceEnabled();
    if ( value == null || rs.wasNull() ) {
        if ( traceEnabled ) {
            log.tracef(
                    "extracted value ([%s] : [%s]) - [null]",
                    name,
                    JdbcTypeNameMapper.getTypeName( getSqlDescriptor().getSqlType() )
            );
        }
        return null;
    }
    else {
        if ( traceEnabled ) {
            log.tracef(
                    "extracted value ([%s] : [%s]) - [%s]",
                    name,
                    JdbcTypeNameMapper.getTypeName( getSqlDescriptor().getSqlType() ),
                    getJavaDescriptor().extractLoggableRepresentation( value )
            );
        }
        return value;
    }
}
项目:lams    文件:BasicExtractor.java   
@Override
public J extract(CallableStatement statement, int index, WrapperOptions options) throws SQLException {
    final J value = doExtract( statement, index, options );
    final boolean traceEnabled = log.isTraceEnabled();
    if ( value == null || statement.wasNull() ) {
        if ( traceEnabled ) {
            log.tracef(
                    "extracted procedure output  parameter ([%s] : [%s]) - [null]",
                    index,
                    JdbcTypeNameMapper.getTypeName( getSqlDescriptor().getSqlType() )
            );
        }
        return null;
    }
    else {
        if ( traceEnabled ) {
            log.tracef(
                    "extracted procedure output  parameter ([%s] : [%s]) - [%s]",
                    index,
                    JdbcTypeNameMapper.getTypeName( getSqlDescriptor().getSqlType() ),
                    getJavaDescriptor().extractLoggableRepresentation( value )
            );
        }
        return value;
    }
}
项目:hibernate-ogm-redis    文件:Base64ByteArrayMappedGridTypeDescriptor.java   
@Override
public <X> GridValueBinder<X> getBinder(final JavaTypeDescriptor<X> javaTypeDescriptor) {
    return new BasicGridBinder<X>( javaTypeDescriptor, this ) {

        @Override
        protected void doBind(Tuple resultset, X value, String[] names, WrapperOptions options) {
            byte[] unwrap = javaTypeDescriptor.unwrap( value, byte[].class, options );
            resultset.put( names[0], Base64ByteArrayTypeDescriptor.INSTANCE.toString( unwrap ) );
        }
    };
}
项目:lams    文件:PostgresUUIDType.java   
public <X> ValueBinder<X> getBinder(final JavaTypeDescriptor<X> javaTypeDescriptor) {
    return new BasicBinder<X>( javaTypeDescriptor, this ) {
        @Override
        protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException {
            st.setObject( index, javaTypeDescriptor.unwrap( value, UUID.class, options ), getSqlType() );
        }
    };
}
项目:hibernate-types    文件:JsonNodeTypeDescriptor.java   
@SuppressWarnings({"unchecked"})
@Override
public <X> X unwrap(JsonNode value, Class<X> type, WrapperOptions options) {
    if (value == null) {
        return null;
    }
    if (String.class.isAssignableFrom(type)) {
        return (X) toString(value);
    }
    if (JsonNode.class.isAssignableFrom(type)) {
        return (X) JacksonUtil.toJsonNode(toString(value));
    }
    throw unknownUnwrap(type);
}
项目:lams    文件:AbstractStandardBasicType.java   
@SuppressWarnings({ "unchecked" })
public final void nullSafeSet(
        PreparedStatement st,
        Object value,
        int index,
        final SessionImplementor session) throws SQLException {
    final WrapperOptions options = getOptions(session);
    nullSafeSet( st, value, index, options );
}
项目:lams    文件:AbstractStandardBasicType.java   
@Override
public T extract(CallableStatement statement, int startIndex, final SessionImplementor session) throws SQLException {
    final WrapperOptions options = getOptions(session);
    return remapSqlTypeDescriptor( options ).getExtractor( javaTypeDescriptor ).extract(
            statement,
            startIndex,
            options
    );
}
项目:hibernate-types    文件:JsonBinarySqlTypeDescriptor.java   
@Override
public <X> ValueBinder<X> getBinder(final JavaTypeDescriptor<X> javaTypeDescriptor) {
    return new BasicBinder<X>(javaTypeDescriptor, this) {
        @Override
        protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException {
            st.setObject(index, javaTypeDescriptor.unwrap(value, JsonNode.class, options), getSqlType());
        }
    };
}
项目:hibernate-types    文件:JsonTypeDescriptor.java   
@SuppressWarnings({"unchecked"})
@Override
public <X> X unwrap(Object value, Class<X> type, WrapperOptions options) {
    if (value == null) {
        return null;
    }
    if (String.class.isAssignableFrom(type)) {
        return (X) toString(value);
    }
    if (Object.class.isAssignableFrom(type)) {
        return (X) JacksonUtil.toJsonNode(toString(value));
    }
    throw unknownUnwrap(type);
}
项目:lams    文件:BigIntegerTypeDescriptor.java   
@Override
@SuppressWarnings({ "unchecked" })
public <X> X unwrap(BigInteger value, Class<X> type, WrapperOptions options) {
    if ( value == null ) {
        return null;
    }
    if ( BigInteger.class.isAssignableFrom( type ) ) {
        return (X) value;
    }
    if ( BigDecimal.class.isAssignableFrom( type ) ) {
        return (X) new BigDecimal( value );
    }
    if ( Byte.class.isAssignableFrom( type ) ) {
        return (X) Byte.valueOf( value.byteValue() );
    }
    if ( Short.class.isAssignableFrom( type ) ) {
        return (X) Short.valueOf( value.shortValue() );
    }
    if ( Integer.class.isAssignableFrom( type ) ) {
        return (X) Integer.valueOf( value.intValue() );
    }
    if ( Long.class.isAssignableFrom( type ) ) {
        return (X) Long.valueOf( value.longValue() );
    }
    if ( Double.class.isAssignableFrom( type ) ) {
        return (X) Double.valueOf( value.doubleValue() );
    }
    if ( Float.class.isAssignableFrom( type ) ) {
        return (X) Float.valueOf( value.floatValue() );
    }
    throw unknownUnwrap( type );
}
项目:hibernate-json-type    文件:JsonJavaTypeDescriptor.java   
@Override
public <X> X unwrap(JsonStructure value, Class<X> type, WrapperOptions options) {
    if (value == null) {
        return null;
    }

    if (String.class.isAssignableFrom(type)) {
        return (X) this.toString(value);
    }

    throw unknownUnwrap(type);
}