Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repeated elements in collections are removed #103

Open
damiancalabresi opened this issue Jan 13, 2016 · 1 comment
Open

Repeated elements in collections are removed #103

damiancalabresi opened this issue Jan 13, 2016 · 1 comment
Labels

Comments

@damiancalabresi
Copy link

Hi, In my case the entity Sharing has a list of User, the entity SharingDoc has an a list of userId.

public class Sharing extends BaseEntity{
  private List<User> sharedWith;
}

public class User extends BaseEntity {
  private Long id;
}
public class SharingDoc extends BaseEntity{
  private List<Long> sharedWith;
}

I have the following mapping:

mapperFactory.classMap(Sharing.class, SharingDoc.class)
  .field("sharedWith{id}", "sharedWith{}") // Test this!!
  .byDefault()
  .register();

I made a test where I create a Sharing entity with three users, the user.id are 1L, 2L and 2L (Yes, it's repeated)

Original Sharing:

{
  "sharedWith": [
    { "id": 1},
    { "id": 2},
    { "id": 2}
  ]
}

Mapped SharingDoc:

{
  "sharedWith": [
    1,
    2,
    2
  ]
}

I did the inverse mapping, so, the final Sharing entity is:

{
  "sharedWith": [
    { "id": 1},
    { "id": 2}
  ]
}

One user has disappeared. In some cases, it could be important.

@ndr-brt ndr-brt added the bug label Nov 9, 2016
@ndr-brt
Copy link
Collaborator

ndr-brt commented Nov 9, 2016

it happens when equal items are nearby, because MultiOccurrenceToMultiOccurrence verifies that item is different from the precedent item (due to some strange grouping specification, as listed in ExpanderTestCase).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants