Class SqlResultEntityTypeMapper<RS,R>

java.lang.Object
io.micronaut.data.runtime.mapper.sql.SqlResultEntityTypeMapper<RS,R>
Type Parameters:
RS - The result set type
R - The result type
All Implemented Interfaces:
SqlTypeMapper<RS,R>, TypeMapper<RS,R>

@Internal public final class SqlResultEntityTypeMapper<RS,R> extends Object implements SqlTypeMapper<RS,R>
A TypeMapper that can take a RuntimePersistentEntity and a ResultReader and materialize an instance using column naming conventions mapped by the entity.
  • Constructor Details

    • SqlResultEntityTypeMapper

      public SqlResultEntityTypeMapper(String prefix, @NonNull @NonNull RuntimePersistentEntity<R> entity, @NonNull @NonNull ResultReader<RS,String> resultReader, @Nullable @Nullable SqlJsonColumnReader<RS> jsonColumnReader, DataConversionService conversionService)
      Default constructor.
      Parameters:
      prefix - The prefix to startup from.
      entity - The entity
      resultReader - The result reader
      jsonColumnReader - The json column reader
      conversionService - The conversion service
    • SqlResultEntityTypeMapper

      public SqlResultEntityTypeMapper(@NonNull @NonNull RuntimePersistentEntity<R> entity, @NonNull @NonNull ResultReader<RS,String> resultReader, @Nullable @Nullable Set<JoinPath> joinPaths, @Nullable @Nullable SqlJsonColumnReader<RS> jsonColumnReader, DataConversionService conversionService)
      Constructor used to customize the join paths.
      Parameters:
      entity - The entity
      resultReader - The result reader
      joinPaths - The join paths
      jsonColumnReader - The json column reader
      conversionService - The conversion service
    • SqlResultEntityTypeMapper

      public SqlResultEntityTypeMapper(@NonNull @NonNull RuntimePersistentEntity<R> entity, @NonNull @NonNull ResultReader<RS,String> resultReader, @Nullable @Nullable Set<JoinPath> joinPaths, @Nullable @Nullable SqlJsonColumnReader<RS> jsonColumnReader, @Nullable @Nullable BiFunction<RuntimePersistentEntity<Object>,Object,Object> loadListener, DataConversionService conversionService)
      Constructor used to customize the join paths.
      Parameters:
      entity - The entity
      resultReader - The result reader
      joinPaths - The join paths
      jsonColumnReader - The json column reader
      loadListener - The event listener
      conversionService - The conversion service
  • Method Details

    • getConversionService

      public DataConversionService getConversionService()
      Specified by:
      getConversionService in interface TypeMapper<RS,R>
      Returns:
      The conversion service to use.
    • getEntity

      @NonNull public @NonNull RuntimePersistentEntity<R> getEntity()
      Returns:
      The entity to be materialized
    • getResultReader

      @NonNull public @NonNull ResultReader<RS,String> getResultReader()
      Returns:
      The result reader instance.
    • map

      @NonNull public R map(@NonNull RS rs, @NonNull @NonNull Class<R> type) throws DataAccessException
      Description copied from interface: TypeMapper
      Map the given result set to the given object.
      Specified by:
      map in interface TypeMapper<RS,R>
      Parameters:
      rs - The object to map
      type - The type
      Returns:
      The mapped object
      Throws:
      DataAccessException - If the object cannot be mapped.
    • readEntity

      @NonNull public R readEntity(@NonNull RS rs)
      Read the entity from the result set.
      Parameters:
      rs - The result set
      Returns:
      The entity
      Since:
      4.2.0
    • read

      @Nullable public @Nullable Object read(@NonNull RS resultSet, @NonNull @NonNull String name)
      Description copied from interface: TypeMapper
      Read a value for the given name from the given object.
      Specified by:
      read in interface TypeMapper<RS,R>
      Parameters:
      resultSet - The object to read from
      name - The name
      Returns:
      The value
    • read

      @Nullable public @Nullable Object read(@NonNull RS resultSet, @NonNull @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 interface TypeMapper<RS,R>
      Parameters:
      resultSet - The object to read from
      argument - The argument
      Returns:
      The value
    • hasNext

      public boolean hasNext(RS resultSet)
      Description copied from interface: SqlTypeMapper
      Is another result available.
      Specified by:
      hasNext in interface SqlTypeMapper<RS,R>
      Parameters:
      resultSet - The result set
      Returns:
      True if it is
    • readOneMapper

      public SqlResultEntityTypeMapper.PushingMapper<RS,R> readOneMapper()
      Read one entity with a pushing mapper.
      Returns:
      The pushing mapper
    • readManyMapper

      public SqlResultEntityTypeMapper.PushingMapper<RS,List<R>> readManyMapper()
      Read multiple entities with a pushing mapper.
      Returns:
      The pushing mapper
    • getPersistentEntity

      public RuntimePersistentEntity<R> getPersistentEntity()