Java 类org.hibernate.type.descriptor.java.JavaTypeDescriptor 实例源码

项目:hibernate-ogm-redis    文件:Base64ByteArrayMappedGridTypeDescriptor.java   
@Override
public <X> GridValueExtractor<X> getExtractor(final JavaTypeDescriptor<X> javaTypeDescriptor) {
    return new GridValueExtractor<X>() {

        @Override
        public X extract(Tuple resultset, String name) {
            final X result = (X) resultset.get( name );
            if ( result == null ) {
                return null;
            }
            else {
                byte[] bytes = Base64ByteArrayTypeDescriptor.INSTANCE.fromString( (String) result );
                return javaTypeDescriptor.wrap( bytes, null );
            }
        }
    };
}
项目: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    文件:AbstractHANADialect.java   
@Override
public <X> BasicBinder<X> getNClobBinder(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 NClobImplementer ) {
                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   
@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    文件: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 );
        }
    };
}
项目:hibernate-json-type    文件:JsonTypeContributor.java   
@Override
public void contribute(TypeContributions typeContributions, ServiceRegistry serviceRegistry) {
    JsonType jtype;
    JavaTypeDescriptor jdesc;
    try {
        jtype = JsonType.INSTANCE;
        jdesc = JsonJavaTypeDescriptor.INSTANCE;
    }
    catch (Throwable t) {
        // Avoid logging system for a project so small
        System.err.println("JSON type contribution failed! Message: " + t.getMessage());
        t.printStackTrace(System.err);
        return;
    }
    JavaTypeDescriptorRegistry.INSTANCE.addDescriptor(jdesc);
    typeContributions.contributeType(jtype);
}
项目:windup-rulesets    文件:DstSafeDateTypeDescriptor.java   
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);  
   } 
  } 
 }; 
}
项目:debop4j    文件:CustomDateType.java   
@Override
public <X> GridValueExtractor<X> getExtractor(JavaTypeDescriptor<X> javaTypeDescriptor) {
    return new GridValueExtractor<X>() {
        @Override
        public X extract(Tuple resultset, String name) {
            final String result = (String) resultset.get(name);
            if (result == null) {
                log.tracef("found [null] as column [$s]", name);
                return null;
            } else {
                Date date = null;
                try {
                    date = new SimpleDateFormat("yyyyMMdd").parse(result);
                } catch (ParseException e) {
                    throw new HibernateException("Unable to read date from datastore " + result, e);
                }
                {
                    log.tracef("found [$s] as column [$s]", result, name);
                }
                return (X) date;
            }
        }
    };
}
项目: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() );
        }
    };
}
项目:lams    文件:AttributeConverterTypeAdapter.java   
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 );
}
项目:lams    文件:AttributeConverterSqlTypeDescriptorAdapter.java   
public AttributeConverterSqlTypeDescriptorAdapter(
        AttributeConverter converter,
        SqlTypeDescriptor delegate,
        JavaTypeDescriptor intermediateJavaTypeDescriptor) {
    this.converter = converter;
    this.delegate = delegate;
    this.intermediateJavaTypeDescriptor = intermediateJavaTypeDescriptor;
}
项目: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 {
            if ( options.useStreamForLobBinding() ) {
                STREAM_BINDING.getClobBinder( javaTypeDescriptor ).doBind( st, value, index, options );
            }
            else {
                CLOB_BINDING.getClobBinder( javaTypeDescriptor ).doBind( st, value, index, options );
            }
        }
    };
}
项目: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 {
            final CharacterStream characterStream = javaTypeDescriptor.unwrap( value, CharacterStream.class, options );
            st.setCharacterStream( index, characterStream.asReader(), characterStream.getLength() );
        }
    };
}
项目: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 {
            final CharacterStream characterStream = javaTypeDescriptor.unwrap( value, CharacterStream.class, options );
            st.setCharacterStream( index, characterStream.asReader(), characterStream.getLength() );
        }
    };
}
项目:lams    文件:BooleanTypeDescriptor.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.setBoolean( index, javaTypeDescriptor.unwrap( value, Boolean.class, options ) );
        }
    };
}
项目:lams    文件:NClobTypeDescriptor.java   
@Override
            public <X> BasicBinder<X> getNClobBinder(final JavaTypeDescriptor<X> javaTypeDescriptor) {
    return new BasicBinder<X>( javaTypeDescriptor, this ) {
        @Override
        protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException {
            if ( options.useStreamForLobBinding() ) {
                STREAM_BINDING.getNClobBinder( javaTypeDescriptor ).doBind( st, value, index, options );
            }
            else {
                NCLOB_BINDING.getNClobBinder( javaTypeDescriptor ).doBind( st, value, index, options );
            }
        }
    };
}
项目:lams    文件:NClobTypeDescriptor.java   
@Override
            public <X> BasicBinder<X> getNClobBinder(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.setNClob( index, javaTypeDescriptor.unwrap( value, NClob.class, options ) );
        }
    };
}
项目:lams    文件:NClobTypeDescriptor.java   
@Override
            public <X> BasicBinder<X> getNClobBinder(final JavaTypeDescriptor<X> javaTypeDescriptor) {
    return new BasicBinder<X>( javaTypeDescriptor, this ) {
        @Override
        protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options)
                throws SQLException {
            final CharacterStream characterStream = javaTypeDescriptor.unwrap( value, CharacterStream.class, options );
            st.setCharacterStream( index, characterStream.asReader(), characterStream.getLength() );
        }
    };
}
项目:lams    文件:TimeTypeDescriptor.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.setTime( index, javaTypeDescriptor.unwrap( value, Time.class, options ) );
        }
    };
}
项目:lams    文件:VarbinaryTypeDescriptor.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.setBytes( index, javaTypeDescriptor.unwrap( value, byte[].class, options ) );
        }
    };
}
项目:lams    文件:SqlTypeDescriptorRegistry.java   
@Override
public <X> ValueBinder<X> getBinder(JavaTypeDescriptor<X> javaTypeDescriptor) {
    if ( Serializable.class.isAssignableFrom( javaTypeDescriptor.getJavaTypeClass() ) ) {
        return VarbinaryTypeDescriptor.INSTANCE.getBinder( javaTypeDescriptor );
    }

    return new BasicBinder<X>( javaTypeDescriptor, this ) {
        @Override
        protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options)
                throws SQLException {
            st.setObject( index, value, jdbcTypeCode );
        }
    };
}
项目:lams    文件:BigIntTypeDescriptor.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.setLong( index, javaTypeDescriptor.unwrap( value, Long.class, options ) );
        }
    };
}
项目:lams    文件:TimestampTypeDescriptor.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.setTimestamp( index, javaTypeDescriptor.unwrap( value, Timestamp.class, options ) );
        }
    };
}
项目:lams    文件:DoubleTypeDescriptor.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.setDouble( index, javaTypeDescriptor.unwrap( value, Double.class, options ) );
        }
    };
}
项目:lams    文件:SmallIntTypeDescriptor.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.setShort( index, javaTypeDescriptor.unwrap( value, Short.class, options ) );
        }
    };
}
项目:lams    文件:DecimalTypeDescriptor.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.setBigDecimal( index, javaTypeDescriptor.unwrap( value, BigDecimal.class, options ) );
        }
    };
}
项目:lams    文件:BlobTypeDescriptor.java   
@Override
public <X> BasicBinder<X> getBlobBinder(final JavaTypeDescriptor<X> javaTypeDescriptor) {
    return new BasicBinder<X>( javaTypeDescriptor, this ) {
        @Override
        public void doBind(PreparedStatement st, X value, int index, WrapperOptions options)
                throws SQLException {
            st.setBytes( index, javaTypeDescriptor.unwrap( value, byte[].class, options ) );
        }
    };
}
项目: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 {
            st.setBlob( index, javaTypeDescriptor.unwrap( value, Blob.class, options ) );
        }
    };
}
项目: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 {
            final BinaryStream binaryStream = javaTypeDescriptor.unwrap(
                    value,
                    BinaryStream.class,
                    options
            );
            st.setBinaryStream( index, binaryStream.getInputStream(), binaryStream.getLength() );
        }
    };
}
项目:lams    文件:RealTypeDescriptor.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.setFloat( index, javaTypeDescriptor.unwrap( value, Float.class, options ) );
        }
    };
}
项目:lams    文件:IntegerTypeDescriptor.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.setInt( index, javaTypeDescriptor.unwrap( value, Integer.class, options ) );
        }
    };
}
项目:lams    文件:VarcharTypeDescriptor.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.setString( index, javaTypeDescriptor.unwrap( value, String.class, options ) );
        }
    };
}
项目:lams    文件:DateTypeDescriptor.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.setDate( index, javaTypeDescriptor.unwrap( value, Date.class, options ) );
        }
    };
}
项目:lams    文件:NVarcharTypeDescriptor.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.setNString( index, javaTypeDescriptor.unwrap( value, String.class, options ) );
        }
    };
}
项目:lams    文件:BitTypeDescriptor.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.setBoolean( index, javaTypeDescriptor.unwrap( value, Boolean.class, options ) );
        }
    };
}
项目:lams    文件:TinyIntTypeDescriptor.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.setByte( index, javaTypeDescriptor.unwrap( value, Byte.class, options ) );
        }
    };
}
项目:hibernate-ogm-ignite    文件:IgniteGridTypeDescriptor.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) {
            resultset.put( names[0], javaTypeDescriptor.unwrap( value, targetClass, options ) );
        }
    };
}
项目:hibernate-types    文件:ArraySqlTypeDescriptor.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 {
            AbstractArrayTypeDescriptor<Object> abstractArrayTypeDescriptor = (AbstractArrayTypeDescriptor<Object>) javaTypeDescriptor;
            st.setArray(index, st.getConnection().createArrayOf(
                    abstractArrayTypeDescriptor.getSqlArrayType(),
                    abstractArrayTypeDescriptor.unwrap(value, Object[].class, options)
            ));
        }
    };
}