paulcwarren/spring-content

Using the same nested content property class, only the first one is processed

Closed this issue · 0 comments

Describe the bug

Given an entity that contains multiple fields of a type, with that type containing spring-content annotated fields, only the first field is recognized as a content property.

class Contract {
  @Id
  private UUID id;

  private Content document1 = new Content();
  private Content document2 = new Content();
}

class Content {
  @ContentId
  private UUID id;
  @ContentLength
  private long length;
}

Only links for /contracts/<id>/document1 are generated and can be used. Links for /contracts/<id>/document2 are not available in MappingContext, and thus no links to them are generated, and the content is not accessible.

This looks to be caused by a visited class check in ContentPropertyBuilderVisitor, that does not take into account that the same class may be present multiple times during one walk over the class hierarchy.