0

With Spring Hateoas 0.25, we had code like this:

public class StatisticsResource extends Resource<StatisticsDto>
{
    :
}

public class StatisticsResourceAssembler
        extends ResourceAssemblerSupport<StatisticsDto, StatisticsResource>
{
    :
}

Now I'm migrating it to 1.0, like this:

public class StatisticsResource extends EntityModel<StatisticsDto>
{
    :
}

public class StatisticsResourceAssembler
        extends RepresentationModelAssemblerSupport<StatisticsDto, StatisticsResource>
{
    :
}

This however doesn't compile:

extends RepresentationModelAssemblerSupport<StatisticsDto, StatisticsResource>
                                                           ^
where D is a type-variable:
    D extends RepresentationModel<D> declared in class RepresentationModelAssemblerSupport

Any idea what's going wrong here?

Bert
  • 861
  • 9
  • 22
  • Try using [SimpleRepresentationModelAssembler](https://docs.spring.io/spring-hateoas/docs/1.0.1.BUILD-SNAPSHOT/api/org/springframework/hateoas/server/SimpleRepresentationModelAssembler.html) – saifulislampi Nov 07 '19 at 20:08
  • Thanks. That works for this simple case (and makes it even simpler), but I have more complex cases where I need a custom model class and where ``EntityModel`` is a very useful base type. Any further suggestions? – Bert Nov 08 '19 at 06:51

1 Answers1

0

This appears to be a bug in Spring Hateoas, see Generics bounds too strict in RepresentationModelAssemblerSupport. The fix will ship in 1.1.0. Kudos to the Spring Hateaos team!

Thanks

Bert
  • 861
  • 9
  • 22