Skip to content

Constructor creation with bulk fetching of DBRefs uses List instead of collection type [DATAMONGO-1666] #2574

@spring-projects-issues

Description

@spring-projects-issues

Shiv Veeram opened DATAMONGO-1666 and commented

public class Squad {

  @DBRef`monospaced text`
  private final Set<Player> players;

  public Squad(Set<Player> players) {
    this.players = ImmutableSet.copyOf(Objects.requireNonNull(players));
  }

  public Set<Player> getPlayers() {
    return players;
  }

}

The above code fails with

java.lang.IllegalArgumentException: argument type mismatch
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_121]

Both the setter based and field based injection works as expected but we want to make the set immutable.

Can somebody explain why the constructor based style is not working ?


Affects: 2.0 M1 (Kay), 1.10.1 (Ingalls SR1)

Reference URL: http://stackoverflow.com/questions/43294837/referencing-documents-with-dbref-annotation-on-a-set

Referenced from: pull request #457

Backported to: 1.10.2 (Ingalls SR2)

Metadata

Metadata

Assignees

Labels

in: mappingMapping and conversion infrastructuretype: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions