Class JdbcMapperFactory

java.lang.Object
org.simpleflatmapper.map.mapper.AbstractMapperFactory<K,MF,S>
org.simpleflatmapper.map.mapper.AbstractColumnNameDiscriminatorMapperFactory<JdbcColumnKey,JdbcMapperFactory,ResultSet>
org.simpleflatmapper.jdbc.JdbcMapperFactory

public final class JdbcMapperFactory extends org.simpleflatmapper.map.mapper.AbstractColumnNameDiscriminatorMapperFactory<JdbcColumnKey,JdbcMapperFactory,ResultSet>
JdbcMapperFactory allows you to customise the mappers and create an newInstance of it using a fluent syntax.

JdbcMapperFactory is not Thread-Safe but the mappers are. It is strongly advised to instantiate one jdbcMapper per class for the life of your application.

You can instantiate dynamic jdbcMapper which will use the ResultSetMetaData to figure out the list of the columns or a static one using a builder.

// create a dynamic jdbcMapper targeting MyClass
JdbcMapperFactory
    .newInstance()
    .newMapper(MyClass.class);

// create a static jdbcMapper targeting MyClass
JdbcMapperFactory
    .newInstance()
    .newBuilder(MyClass.class)
    .addMapping("id")
    .addMapping("field1")
    .addMapping("field2")
    .mapper();

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
     
    static class 
     

    Nested classes/interfaces inherited from class org.simpleflatmapper.map.mapper.AbstractColumnNameDiscriminatorMapperFactory

    org.simpleflatmapper.map.mapper.AbstractColumnNameDiscriminatorMapperFactory.DiscriminatorNamedGetter<S,T>, org.simpleflatmapper.map.mapper.AbstractColumnNameDiscriminatorMapperFactory.DiscriminatorNamedGetterFactory<S>

    Nested classes/interfaces inherited from class org.simpleflatmapper.map.mapper.AbstractMapperFactory

    org.simpleflatmapper.map.mapper.AbstractMapperFactory.DiscriminatorBuilder<S,K extends org.simpleflatmapper.map.FieldKey<K>,T>, org.simpleflatmapper.map.mapper.AbstractMapperFactory.DiscriminatorConditionBuilder<S,K extends org.simpleflatmapper.map.FieldKey<K>,KT,T>, org.simpleflatmapper.map.mapper.AbstractMapperFactory.DiscriminatorDSL<K extends org.simpleflatmapper.map.FieldKey<K>,MF extends org.simpleflatmapper.map.mapper.AbstractMapperFactory<K,MF,S>,S,T>, org.simpleflatmapper.map.mapper.AbstractMapperFactory.DiscriminatorOnColumnDSL<K extends org.simpleflatmapper.map.FieldKey<K>,MF extends org.simpleflatmapper.map.mapper.AbstractMapperFactory<K,MF,S>,S,T,KT>
  • Field Summary

    Fields inherited from class org.simpleflatmapper.map.mapper.AbstractMapperFactory

    discriminators, getterFactory
  • Method Summary

    Modifier and Type
    Method
    Description
    addCustomFieldMapper(String key, org.simpleflatmapper.map.FieldMapper<ResultSet,?> fieldMapper)
    Associate the specified FieldMapper for the specified property.
    addCustomGetter(String key, org.simpleflatmapper.reflect.Getter<ResultSet,?> getter)
    Associate the specified Getter for the specified property.
    addGetterFactory(org.simpleflatmapper.map.getter.ContextualGetterFactory<ResultSet,JdbcColumnKey> getterFactory)
    Override the default implementation of the GetterFactory used to get access to value from the ResultSet.
    buildFrom(Class<T> target)
     
    buildFrom(Type target)
     
    buildFrom(org.simpleflatmapper.reflect.meta.ClassMeta<T> classMeta)
     
    buildFrom(org.simpleflatmapper.util.TypeReference<T> target)
     
    <T, K> CrudDSL<T,K>
    crud(Class<T> target, Class<K> keyTarget)
     
    <T, K> CrudDSL<T,K>
    crud(Type target, Type keyTarget)
     
    <T, K> CrudDSL<T,K>
    crud(org.simpleflatmapper.reflect.meta.ClassMeta<T> target, org.simpleflatmapper.reflect.meta.ClassMeta<K> keyTarget)
     
    from(Class<T> target)
     
    from(Type target)
     
    from(org.simpleflatmapper.reflect.meta.ClassMeta<T> classMeta)
     
    from(org.simpleflatmapper.util.TypeReference<T> target)
     
    getterFactory(org.simpleflatmapper.reflect.getter.GetterFactory<ResultSet,JdbcColumnKey> getterFactory)
    Override the default implementation of the GetterFactory used to get access to value from the ResultSet.
    newBuilder(Class<T> target)
    Will create a newInstance of JdbcMapperBuilder on the specified target class.
    newBuilder(Type target)
    Will create a newInstance of JdbcMapperBuilder on the specified type.
    newBuilder(org.simpleflatmapper.reflect.meta.ClassMeta<T> classMeta)
     
    newBuilder(org.simpleflatmapper.util.TypeReference<T> target)
    Will create a newInstance of JdbcMapperBuilder on the type T specified by the typeReference.
    Create a discriminator builder based on the specified property
    instantiate a new JdbcMapperFactory
    newInstance(org.simpleflatmapper.map.mapper.AbstractMapperFactory<JdbcColumnKey,?,ResultSet> config)
     
    newMapper(Class<T> target)
    Will create a DynamicMapper on the specified target class.
    <T> JdbcMapper<T>
    newMapper(Class<T> target, ResultSetMetaData metaData)
    Will create a newInstance of JdbcMapper based on the specified metadata and the target class.
    newMapper(Type target)
    Will create a DynamicMapper on the specified type.
    newMapper(org.simpleflatmapper.util.TypeReference<T> target)
    Will create a DynamicMapper on the type specified by the TypeReference.
     

    Methods inherited from class org.simpleflatmapper.map.mapper.AbstractColumnNameDiscriminatorMapperFactory

    discriminator, discriminator, discriminator, discriminator

    Methods inherited from class org.simpleflatmapper.map.mapper.AbstractMapperFactory

    addAlias, addAliases, addAliasForType, addColumnDefinition, addColumnDefinition, addColumnProperty, addColumnProperty, addColumnProperty, addColumnPropertyForType, addColumnPropertyForType, addColumnPropertyForType, addColumnPropertyForType, addGetterForType, addGetterForType, addGetterForType, addGetterForType, addGetterForType, addKeys, asmMapperNbFieldsLimit, assumeInjectionModifiesValues, columnDefinitions, columnDefinitions, consumerErrorHandler, consumerErrorHandler, discriminator, discriminator, discriminator, discriminator, discriminator, discriminator, discriminator, discriminator, enableSpeculativeArrayIndexResolution, enableSpeculativePropertyLookupOnObject, enrichColumnDefinitions, failOnAsm, fieldMapperErrorHandler, getClassMeta, getClassMeta, getClassMeta, getClassMetaWithExtraInstantiator, getClassMetaWithExtraInstantiator, getClassMetaWithExtraInstantiator, getReflectionService, ignoreColumns, ignoreColumns, ignoreColumns, ignorePropertyNotFound, mapperBuilderErrorHandler, mapperConfig, mapperConfig, maxMethodSize, propertyNameMatcherFactory, propertyNameMatcherFactory, reflectionService, rowFilter, rowHandlerErrorHandler, unorderedJoin, useAsm

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • newInstance

      public static JdbcMapperFactory newInstance()
      instantiate a new JdbcMapperFactory
      Returns:
      a new newInstance JdbcMapperFactory
    • newInstance

      public static JdbcMapperFactory newInstance(org.simpleflatmapper.map.mapper.AbstractMapperFactory<JdbcColumnKey,?,ResultSet> config)
    • getterFactory

      public JdbcMapperFactory getterFactory(org.simpleflatmapper.reflect.getter.GetterFactory<ResultSet,JdbcColumnKey> getterFactory)
      Override the default implementation of the GetterFactory used to get access to value from the ResultSet.
      Parameters:
      getterFactory - the getterFactory
      Returns:
      the current factory
    • addGetterFactory

      public JdbcMapperFactory addGetterFactory(org.simpleflatmapper.map.getter.ContextualGetterFactory<ResultSet,JdbcColumnKey> getterFactory)
      Override the default implementation of the GetterFactory used to get access to value from the ResultSet.
      Overrides:
      addGetterFactory in class org.simpleflatmapper.map.mapper.AbstractMapperFactory<JdbcColumnKey,JdbcMapperFactory,ResultSet>
      Parameters:
      getterFactory - the getterFactory
      Returns:
      the current factory
    • addCustomFieldMapper

      public JdbcMapperFactory addCustomFieldMapper(String key, org.simpleflatmapper.map.FieldMapper<ResultSet,?> fieldMapper)
      Associate the specified FieldMapper for the specified property.
      Parameters:
      key - the property
      fieldMapper - the fieldMapper
      Returns:
      the current factory
    • addCustomGetter

      public JdbcMapperFactory addCustomGetter(String key, org.simpleflatmapper.reflect.Getter<ResultSet,?> getter)
      Associate the specified Getter for the specified property.
      Parameters:
      key - the property
      getter - the getter
      Returns:
      the current factory
    • newMapper

      public <T> JdbcMapper<T> newMapper(Class<T> target, ResultSetMetaData metaData) throws SQLException
      Will create a newInstance of JdbcMapper based on the specified metadata and the target class.
      Type Parameters:
      T - the jdbcMapper target type
      Parameters:
      target - the target class of the jdbcMapper
      metaData - the metadata to create the jdbcMapper from
      Returns:
      a jdbcMapper that will map the data represented by the metadata to an newInstance of target
      Throws:
      SQLException - if an error occurs getting the metaData
    • newBuilder

      public <T> JdbcMapperBuilder<T> newBuilder(Class<T> target)
      Will create a newInstance of JdbcMapperBuilder on the specified target class.
      Type Parameters:
      T - the jdbcMapper target type
      Parameters:
      target - the target class
      Returns:
      the builder
    • newBuilder

      public <T> JdbcMapperBuilder<T> newBuilder(org.simpleflatmapper.util.TypeReference<T> target)
      Will create a newInstance of JdbcMapperBuilder on the type T specified by the typeReference.
      Type Parameters:
      T - the jdbcMapper target type
      Parameters:
      target - the typeReference
      Returns:
      the builder
    • newBuilder

      public <T> JdbcMapperBuilder<T> newBuilder(Type target)
      Will create a newInstance of JdbcMapperBuilder on the specified type.
      Type Parameters:
      T - the jdbcMapper target type
      Parameters:
      target - the type
      Returns:
      the builder
    • newBuilder

      public <T> JdbcMapperBuilder<T> newBuilder(org.simpleflatmapper.reflect.meta.ClassMeta<T> classMeta)
    • buildFrom

      public <T> PreparedStatementMapperBuilder<T> buildFrom(Class<T> target)
      Type Parameters:
      T - the type
      Parameters:
      target - the type
      Returns:
      a builder to create a mapper from target to PreparedStatement
    • buildFrom

      public <T> PreparedStatementMapperBuilder<T> buildFrom(Type target)
    • buildFrom

      public <T> PreparedStatementMapperBuilder<T> buildFrom(org.simpleflatmapper.util.TypeReference<T> target)
    • buildFrom

      public <T> PreparedStatementMapperBuilder<T> buildFrom(org.simpleflatmapper.reflect.meta.ClassMeta<T> classMeta)
    • from

      public <T> PreparedStatementMapperBuilder<T> from(Class<T> target)
    • from

      public <T> PreparedStatementMapperBuilder<T> from(Type target)
    • from

      public <T> PreparedStatementMapperBuilder<T> from(org.simpleflatmapper.util.TypeReference<T> target)
    • from

      public <T> PreparedStatementMapperBuilder<T> from(org.simpleflatmapper.reflect.meta.ClassMeta<T> classMeta)
    • newMapper

      public <T> DynamicJdbcMapper<T> newMapper(Class<T> target)
      Will create a DynamicMapper on the specified target class.
      Type Parameters:
      T - the jdbcMapper target type
      Parameters:
      target - the class
      Returns:
      the DynamicMapper
    • newMapper

      public <T> DynamicJdbcMapper<T> newMapper(org.simpleflatmapper.util.TypeReference<T> target)
      Will create a DynamicMapper on the type specified by the TypeReference.
      Type Parameters:
      T - the jdbcMapper target type
      Parameters:
      target - the TypeReference
      Returns:
      the DynamicMapper
    • crud

      public <T, K> CrudDSL<T,K> crud(Type target, Type keyTarget)
    • crud

      public <T, K> CrudDSL<T,K> crud(org.simpleflatmapper.reflect.meta.ClassMeta<T> target, org.simpleflatmapper.reflect.meta.ClassMeta<K> keyTarget)
    • crud

      public <T, K> CrudDSL<T,K> crud(Class<T> target, Class<K> keyTarget)
    • newMapper

      public <T> DynamicJdbcMapper<T> newMapper(Type target)
      Will create a DynamicMapper on the specified type.
      Type Parameters:
      T - the jdbcMapper target type
      Parameters:
      target - the type
      Returns:
      the DynamicMapper
    • newSourceFieldMapper

      public <T> JdbcSourceFieldMapper<T> newSourceFieldMapper(Type target)
    • newDiscriminator

      public <T> DiscriminatorJdbcBuilder<T> newDiscriminator(String column)
      Create a discriminator builder based on the specified property
      Type Parameters:
      T - the root type of the jdbcMapper
      Parameters:
      column - the discriminator property
      Returns:
      a builder to specify the type mapping