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 ClassesModifier and TypeClassDescriptionstatic classstatic classNested 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 TypeMethodDescriptionaddCustomFieldMapper(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(org.simpleflatmapper.reflect.meta.ClassMeta<T> classMeta) buildFrom(org.simpleflatmapper.util.TypeReference<T> target) <T,K> CrudDSL<T, K> <T,K> CrudDSL<T, K> <T,K> CrudDSL<T, K> crud(org.simpleflatmapper.reflect.meta.ClassMeta<T> target, org.simpleflatmapper.reflect.meta.ClassMeta<K> keyTarget) 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.<T> JdbcMapperBuilder<T>newBuilder(Class<T> target) Will create a newInstance of JdbcMapperBuilder on the specified target class.<T> JdbcMapperBuilder<T>newBuilder(Type target) Will create a newInstance of JdbcMapperBuilder on the specified type.<T> JdbcMapperBuilder<T>newBuilder(org.simpleflatmapper.reflect.meta.ClassMeta<T> classMeta) <T> JdbcMapperBuilder<T>newBuilder(org.simpleflatmapper.util.TypeReference<T> target) Will create a newInstance of JdbcMapperBuilder on the type T specified by the typeReference.<T> DiscriminatorJdbcBuilder<T>newDiscriminator(String column) Create a discriminator builder based on the specified propertystatic JdbcMapperFactoryinstantiate a new JdbcMapperFactorystatic JdbcMapperFactorynewInstance(org.simpleflatmapper.map.mapper.AbstractMapperFactory<JdbcColumnKey, ?, ResultSet> config) <T> DynamicJdbcMapper<T>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.<T> DynamicJdbcMapper<T>Will create a DynamicMapper on the specified type.<T> DynamicJdbcMapper<T>newMapper(org.simpleflatmapper.util.TypeReference<T> target) Will create a DynamicMapper on the type specified by the TypeReference.<T> JdbcSourceFieldMapper<T>newSourceFieldMapper(Type target) Methods inherited from class org.simpleflatmapper.map.mapper.AbstractColumnNameDiscriminatorMapperFactory
discriminator, discriminator, discriminator, discriminatorMethods 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
-
Method Details
-
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:
addGetterFactoryin classorg.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 propertyfieldMapper- 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 propertygetter- the getter- Returns:
- the current factory
-
newMapper
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 jdbcMappermetaData- 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
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
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
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
- Type Parameters:
T- the type- Parameters:
target- the type- Returns:
- a builder to create a mapper from target to PreparedStatement
-
buildFrom
-
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
-
from
-
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
Will create a DynamicMapper on the specified target class.- Type Parameters:
T- the jdbcMapper target type- Parameters:
target- the class- Returns:
- the DynamicMapper
-
newMapper
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
-
crud
public <T,K> CrudDSL<T,K> crud(org.simpleflatmapper.reflect.meta.ClassMeta<T> target, org.simpleflatmapper.reflect.meta.ClassMeta<K> keyTarget) -
crud
-
newMapper
Will create a DynamicMapper on the specified type.- Type Parameters:
T- the jdbcMapper target type- Parameters:
target- the type- Returns:
- the DynamicMapper
-
newSourceFieldMapper
-
newDiscriminator
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
-