{"action":"created","issue":{"url":"https://api.github.com/repos/mapstruct/mapstruct/issues/824","repository_url":"https://api.github.com/repos/mapstruct/mapstruct","labels_url":"https://api.github.com/repos/mapstruct/mapstruct/issues/824/labels{/name}","comments_url":"https://api.github.com/repos/mapstruct/mapstruct/issues/824/comments","events_url":"https://api.github.com/repos/mapstruct/mapstruct/issues/824/events","html_url":"https://github.com/mapstruct/mapstruct/issues/824","id":163905689,"number":824,"title":"Target Bean Factory","user":{"login":"JulianH","id":318613,"avatar_url":"https://avatars.githubusercontent.com/u/318613?v=3","gravatar_id":"","url":"https://api.github.com/users/JulianH","html_url":"https://github.com/JulianH","followers_url":"https://api.github.com/users/JulianH/followers","following_url":"https://api.github.com/users/JulianH/following{/other_user}","gists_url":"https://api.github.com/users/JulianH/gists{/gist_id}","starred_url":"https://api.github.com/users/JulianH/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JulianH/subscriptions","organizations_url":"https://api.github.com/users/JulianH/orgs","repos_url":"https://api.github.com/users/JulianH/repos","events_url":"https://api.github.com/users/JulianH/events{/privacy}","received_events_url":"https://api.github.com/users/JulianH/received_events","type":"User","site_admin":false},"labels":[{"id":80715304,"url":"https://api.github.com/repos/mapstruct/mapstruct/labels/feature","name":"feature","color":"009800","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":10,"created_at":"2016-07-05T17:39:06Z","updated_at":"2016-12-02T06:30:56Z","closed_at":"2016-12-02T06:30:56Z","body":"It would be great if the target bean could be instantiated using a factory, which could use the source bean. The idea is, that the factory could instaniate the instance based on some existing information of the source. What i have in mind is, that the entity could be instantiated by an hibernate query and the mapping method will then update the mapped fields.\n\nThe factory which will instantiate the beans, for example the entity, could look like\n\n``` java\npublic class EntityFactory {\n   public <T> T createEntity(@TargetType Class<T> targetClass, @MappingSource Object source) {\n      // return initialized instance of T\n   }\n}\n```\n\nThe generated mapper could look like\n\n``` java\npublic class EmployeeMapperImpl implements EmployeeMapper {\n\n\n   public Employee convertFromEmployeeDto(EmployeeDto employeeDto) {\n      if ( employeeDto== null ) {\n         return null;\n      }\n\n      Employee employee = this.entityFactory.createEntity(Employee.class, employeeDto);\n      ...\n   }\n}\n```\n\n@gunnarmorling if you give me some hints how to implement this feature, i will try to contribute this to mapstruct.\n"},"comment":{"url":"https://api.github.com/repos/mapstruct/mapstruct/issues/comments/264383999","html_url":"https://github.com/mapstruct/mapstruct/issues/824#issuecomment-264383999","issue_url":"https://api.github.com/repos/mapstruct/mapstruct/issues/824","id":264383999,"user":{"login":"agudian","id":2737102,"avatar_url":"https://avatars.githubusercontent.com/u/2737102?v=3","gravatar_id":"","url":"https://api.github.com/users/agudian","html_url":"https://github.com/agudian","followers_url":"https://api.github.com/users/agudian/followers","following_url":"https://api.github.com/users/agudian/following{/other_user}","gists_url":"https://api.github.com/users/agudian/gists{/gist_id}","starred_url":"https://api.github.com/users/agudian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/agudian/subscriptions","organizations_url":"https://api.github.com/users/agudian/orgs","repos_url":"https://api.github.com/users/agudian/repos","events_url":"https://api.github.com/users/agudian/events{/privacy}","received_events_url":"https://api.github.com/users/agudian/received_events","type":"User","site_admin":false},"created_at":"2016-12-02T06:30:56Z","updated_at":"2016-12-02T06:30:56Z","body":"Merged to master"}}
{"actor":{"display_login":"agudian"}}