{"action":"opened","issue":{"url":"https://api.github.com/repos/orika-mapper/orika/issues/103","labels_url":"https://api.github.com/repos/orika-mapper/orika/issues/103/labels{/name}","comments_url":"https://api.github.com/repos/orika-mapper/orika/issues/103/comments","events_url":"https://api.github.com/repos/orika-mapper/orika/issues/103/events","html_url":"https://github.com/orika-mapper/orika/issues/103","id":126434345,"number":103,"title":"Repeated elements in collections are removed","user":{"login":"damiancalabresi","id":2768368,"avatar_url":"https://avatars.githubusercontent.com/u/2768368?v=3","gravatar_id":"","url":"https://api.github.com/users/damiancalabresi","html_url":"https://github.com/damiancalabresi","followers_url":"https://api.github.com/users/damiancalabresi/followers","following_url":"https://api.github.com/users/damiancalabresi/following{/other_user}","gists_url":"https://api.github.com/users/damiancalabresi/gists{/gist_id}","starred_url":"https://api.github.com/users/damiancalabresi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/damiancalabresi/subscriptions","organizations_url":"https://api.github.com/users/damiancalabresi/orgs","repos_url":"https://api.github.com/users/damiancalabresi/repos","events_url":"https://api.github.com/users/damiancalabresi/events{/privacy}","received_events_url":"https://api.github.com/users/damiancalabresi/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-01-13T14:49:54Z","updated_at":"2016-01-13T14:49:54Z","closed_at":null,"body":"Hi, In my case the entity Sharing has a list of User, the entity SharingDoc has an a list of userId.\r\n\r\n```java\r\npublic class Sharing extends BaseEntity{\r\n  private List<User> sharedWith;\r\n}\r\n\r\npublic class User extends BaseEntity {\r\n  private Long id;\r\n}\r\n```\r\n\r\n```java\r\npublic class SharingDoc extends BaseEntity{\r\n  private List<Long> sharedWith;\r\n}\r\n```\r\n\r\nI have the following mapping:\r\n\r\n```java\r\nmapperFactory.classMap(Sharing.class, SharingDoc.class)\r\n  .field(\"sharedWith{id}\", \"sharedWith{}\") // Test this!!\r\n  .byDefault()\r\n  .register();\r\n```\r\n\r\nI made a test where I create a Sharing entity with three users, the user.id are 1L, 2L and 2L (Yes, it's repeated)\r\n\r\nOriginal Sharing:\r\n```json\r\n{\r\n  \"sharedWith\": [\r\n    { \"id\": 1l},\r\n    { \"id\": 2l},\r\n    { \"id\": 2l}\r\n  ]\r\n}\r\n```\r\n\r\nMapped SharingDoc:\r\n```json\r\n{\r\n  \"sharedWith\": [\r\n    1l,\r\n    2l,\r\n    2l\r\n  ]\r\n}\r\n```\r\n\r\nI did the inverse mapping, so, the final Sharing entity is:\r\n```json\r\n{\r\n  \"sharedWith\": [\r\n    { \"id\": 1l},\r\n    { \"id\": 2l}\r\n  ]\r\n}\r\n```\r\n\r\nOne user has disappeared. In some cases, it could be important.\r\n"}}