Class 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 java.lang.Object
    implements SqlTypeMapper<RS,​R>
    A TypeMapper that can take a RuntimePersistentEntity and a ResultReader and materialize an instance using using column naming conventions mapped by the entity.
    • 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 entity
        resultReader - The result reader
        jsonCodec - The JSON codec
        conversionService - 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 entity
        resultReader - The result reader
        joinPaths - The join paths
        jsonCodec - The JSON codec
        conversionService - 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 entity
        resultReader - The result reader
        joinPaths - The join paths
        jsonCodec - The JSON codec
        loadListener - The event listener
        conversionService - The conversion service
    • Method Detail

      • 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 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.
      • 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 interface TypeMapper<RS,​R>
        Parameters:
        resultSet - The object to read from
        name - 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 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