spring-data-rest icon indicating copy to clipboard operation
spring-data-rest copied to clipboard

AggregateReference bug

Open jacko9et opened this issue 2 years ago • 4 comments

Referring to the usage method of the document:

  @GetMapping(path = "/scanners")
  ResponseEntity<?> getProducers(
    @RequestParam AggregateReference<Producer, ProducerIdentifier> producer) {

    var identifier = producer.resolveRequiredId();
    // Alternatively
    var aggregate = producer.resolveRequiredAggregate();
  }

The following information is returned:

Source to convert from must be an instance of [java.lang.String]; instead it was a [java.net.URI]

jacko9et avatar Oct 23 '23 09:10 jacko9et

If you would like us to spend some time helping you to diagnose the problem, please spend some time describing it and, ideally, providing a minimal yet complete sample that reproduces the problem. You can share it with us by pushing it to a separate repository on GitHub or by zipping it up and attaching it to this issue.

mp911de avatar Oct 23 '23 14:10 mp911de

I've created a minimal example to reproduce the issue. https://github.com/jacko9et/spring-data-rest-demo

jacko9et avatar Oct 23 '23 14:10 jacko9et

There is no support for resolving a URI to an AggregateReference instance yet. Any reason you're not simply declaring the Producer as parameter type?

An already fully supported alternative to AggregateReference is jMolecules' Association which is essentially the same as AR, independent of Spring Data, but fully supported through automatically registered converters via the org.jmolecules.integrations:jmolecules-spring artifact.

odrotbohm avatar Nov 16 '23 15:11 odrotbohm

@odrotbohm Thank you for your reply. I would like the custom controller's parameters to be able to resolve the uri to the entity to comply with hateoas usage, but it cannot be resolved automatically. I tried adding the annotation @Param or @RequestParam to the entity type, but it didn't work. Is there any arbitrary way to parse uri to entities?

jacko9et avatar Nov 17 '23 01:11 jacko9et