Class SqlResultEntityTypeMapper<RS,R>
- java.lang.Object
-
- io.micronaut.data.runtime.mapper.sql.SqlResultEntityTypeMapper<RS,R>
-
- Type Parameters:
RS- The result set typeR- The result type
- All Implemented Interfaces:
SqlTypeMapper<RS,R>,TypeMapper<RS,R>
@Internal public final class SqlResultEntityTypeMapper<RS,R> extends java.lang.Object implements SqlTypeMapper<RS,R>
ATypeMapperthat can take aRuntimePersistentEntityand aResultReaderand materialize an instance using using column naming conventions mapped by the entity.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceSqlResultEntityTypeMapper.PushingMapper<RS,R>The pushing mapper helper interface.
-
Constructor Summary
Constructors Constructor Description SqlResultEntityTypeMapper(io.micronaut.data.model.runtime.RuntimePersistentEntity<R> entity, ResultReader<RS,java.lang.String> resultReader, java.util.Set<io.micronaut.data.model.query.JoinPath> joinPaths, io.micronaut.http.codec.MediaTypeCodec jsonCodec, DataConversionService<?> conversionService)Constructor used to customize the join paths.SqlResultEntityTypeMapper(io.micronaut.data.model.runtime.RuntimePersistentEntity<R> entity, ResultReader<RS,java.lang.String> resultReader, java.util.Set<io.micronaut.data.model.query.JoinPath> joinPaths, io.micronaut.http.codec.MediaTypeCodec jsonCodec, java.util.function.BiFunction<io.micronaut.data.model.runtime.RuntimePersistentEntity<java.lang.Object>,java.lang.Object,java.lang.Object> loadListener, DataConversionService<?> conversionService)Constructor used to customize the join paths.SqlResultEntityTypeMapper(java.lang.String prefix, io.micronaut.data.model.runtime.RuntimePersistentEntity<R> entity, ResultReader<RS,java.lang.String> resultReader, io.micronaut.http.codec.MediaTypeCodec jsonCodec, DataConversionService<?> conversionService)Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DataConversionService<?>getConversionService()io.micronaut.data.model.runtime.RuntimePersistentEntity<R>getEntity()io.micronaut.data.model.runtime.RuntimePersistentEntity<R>getPersistentEntity()ResultReader<RS,java.lang.String>getResultReader()booleanhasNext(RS resultSet)Is another result available.Rmap(RS rs, java.lang.Class<R> type)Map the given result set to the given object.java.lang.Objectread(RS resultSet, io.micronaut.core.type.Argument<?> argument)Read a value for the given name from the given object.java.lang.Objectread(RS resultSet, java.lang.String name)Read a value for the given name from the given object.SqlResultEntityTypeMapper.PushingMapper<RS,java.util.List<R>>readAllWithJoins()Read multiple entities with a pushing mapper.SqlResultEntityTypeMapper.PushingMapper<RS,R>readOneWithJoins()Read one entity with a pushing mapper.
-
-
-
Constructor Detail
-
SqlResultEntityTypeMapper
public SqlResultEntityTypeMapper(java.lang.String prefix, @NonNull io.micronaut.data.model.runtime.RuntimePersistentEntity<R> entity, @NonNull ResultReader<RS,java.lang.String> resultReader, @Nullable io.micronaut.http.codec.MediaTypeCodec jsonCodec, DataConversionService<?> conversionService)Default constructor.- Parameters:
prefix- The prefix to startup from.entity- The entityresultReader- The result readerjsonCodec- The JSON codecconversionService- The conversion service
-
SqlResultEntityTypeMapper
public SqlResultEntityTypeMapper(@NonNull io.micronaut.data.model.runtime.RuntimePersistentEntity<R> entity, @NonNull ResultReader<RS,java.lang.String> resultReader, @Nullable java.util.Set<io.micronaut.data.model.query.JoinPath> joinPaths, @Nullable io.micronaut.http.codec.MediaTypeCodec jsonCodec, DataConversionService<?> conversionService)Constructor used to customize the join paths.- Parameters:
entity- The entityresultReader- The result readerjoinPaths- The join pathsjsonCodec- The JSON codecconversionService- The conversion service
-
SqlResultEntityTypeMapper
public SqlResultEntityTypeMapper(@NonNull io.micronaut.data.model.runtime.RuntimePersistentEntity<R> entity, @NonNull ResultReader<RS,java.lang.String> resultReader, @Nullable java.util.Set<io.micronaut.data.model.query.JoinPath> joinPaths, @Nullable io.micronaut.http.codec.MediaTypeCodec jsonCodec, @Nullable java.util.function.BiFunction<io.micronaut.data.model.runtime.RuntimePersistentEntity<java.lang.Object>,java.lang.Object,java.lang.Object> loadListener, DataConversionService<?> conversionService)Constructor used to customize the join paths.- Parameters:
entity- The entityresultReader- The result readerjoinPaths- The join pathsjsonCodec- The JSON codecloadListener- The event listenerconversionService- The conversion service
-
-
Method Detail
-
getConversionService
public DataConversionService<?> getConversionService()
- Specified by:
getConversionServicein interfaceTypeMapper<RS,R>- Returns:
- The conversion service to use.
-
getEntity
@NonNull public io.micronaut.data.model.runtime.RuntimePersistentEntity<R> getEntity()
- Returns:
- The entity to be materialized
-
getResultReader
@NonNull public ResultReader<RS,java.lang.String> getResultReader()
- Returns:
- The result reader instance.
-
map
@NonNull public R map(@NonNull RS rs, @NonNull java.lang.Class<R> type) throws io.micronaut.data.exceptions.DataAccessException
Description copied from interface:TypeMapperMap the given result set to the given object.- Specified by:
mapin interfaceTypeMapper<RS,R>- Parameters:
rs- The object to maptype- The type- Returns:
- The mapped object
- Throws:
io.micronaut.data.exceptions.DataAccessException- If the object cannot be mapped.
-
read
@Nullable public java.lang.Object read(@NonNull RS resultSet, @NonNull java.lang.String name)Description copied from interface:TypeMapperRead a value for the given name from the given object.- Specified by:
readin interfaceTypeMapper<RS,R>- Parameters:
resultSet- The object to read fromname- The name- Returns:
- The value
-
read
@Nullable public java.lang.Object read(@NonNull RS resultSet, @NonNull io.micronaut.core.type.Argument<?> argument)Description copied from interface:TypeMapperRead a value for the given name from the given object.- Specified by:
readin interfaceTypeMapper<RS,R>- Parameters:
resultSet- The object to read fromargument- The argument- Returns:
- The value
-
hasNext
public boolean hasNext(RS resultSet)
Description copied from interface:SqlTypeMapperIs another result available.- Specified by:
hasNextin interfaceSqlTypeMapper<RS,R>- Parameters:
resultSet- The result set- Returns:
- True if it is
-
readOneWithJoins
public SqlResultEntityTypeMapper.PushingMapper<RS,R> readOneWithJoins()
Read one entity with a pushing mapper.- Returns:
- The pushing mapper
-
readAllWithJoins
public SqlResultEntityTypeMapper.PushingMapper<RS,java.util.List<R>> readAllWithJoins()
Read multiple entities with a pushing mapper.- Returns:
- The pushing mapper
-
getPersistentEntity
public io.micronaut.data.model.runtime.RuntimePersistentEntity<R> getPersistentEntity()
-
-