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>
ATypeMapper
that can take aRuntimePersistentEntity
and aResultReader
and materialize an instance using using column naming conventions mapped by the entity.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
SqlResultEntityTypeMapper.PushingMapper<RS,R>
The pushing mapper helper interface.
-
Constructor Summary
Constructors Constructor Description SqlResultEntityTypeMapper(RuntimePersistentEntity<R> entity, ResultReader<RS,java.lang.String> resultReader, java.util.Set<JoinPath> joinPaths, io.micronaut.http.codec.MediaTypeCodec jsonCodec, DataConversionService<?> conversionService)
Constructor used to customize the join paths.SqlResultEntityTypeMapper(RuntimePersistentEntity<R> entity, ResultReader<RS,java.lang.String> resultReader, java.util.Set<JoinPath> joinPaths, io.micronaut.http.codec.MediaTypeCodec jsonCodec, java.util.function.BiFunction<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, 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()
RuntimePersistentEntity<R>
getEntity()
RuntimePersistentEntity<R>
getPersistentEntity()
ResultReader<RS,java.lang.String>
getResultReader()
boolean
hasNext(RS resultSet)
Is another result available.R
map(RS rs, java.lang.Class<R> type)
Map the given result set to the given object.java.lang.Object
read(RS resultSet, io.micronaut.core.type.Argument<?> argument)
Read a value for the given name from the given object.java.lang.Object
read(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 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 RuntimePersistentEntity<R> entity, @NonNull ResultReader<RS,java.lang.String> resultReader, @Nullable java.util.Set<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 RuntimePersistentEntity<R> entity, @NonNull ResultReader<RS,java.lang.String> resultReader, @Nullable java.util.Set<JoinPath> joinPaths, @Nullable io.micronaut.http.codec.MediaTypeCodec jsonCodec, @Nullable java.util.function.BiFunction<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:
getConversionService
in interfaceTypeMapper<RS,R>
- Returns:
- The conversion service to use.
-
getEntity
@NonNull public 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 DataAccessException
Description copied from interface:TypeMapper
Map the given result set to the given object.- Specified by:
map
in interfaceTypeMapper<RS,R>
- Parameters:
rs
- The object to maptype
- The type- Returns:
- The mapped object
- Throws:
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:TypeMapper
Read a value for the given name from the given object.- Specified by:
read
in 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:TypeMapper
Read a value for the given name from the given object.- Specified by:
read
in 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:SqlTypeMapper
Is another result available.- Specified by:
hasNext
in 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 RuntimePersistentEntity<R> getPersistentEntity()
-
-