{"action":"created","issue":{"url":"https://api.github.com/repos/mapstruct/mapstruct/issues/778","repository_url":"https://api.github.com/repos/mapstruct/mapstruct","labels_url":"https://api.github.com/repos/mapstruct/mapstruct/issues/778/labels{/name}","comments_url":"https://api.github.com/repos/mapstruct/mapstruct/issues/778/comments","events_url":"https://api.github.com/repos/mapstruct/mapstruct/issues/778/events","html_url":"https://github.com/mapstruct/mapstruct/issues/778","id":140385012,"number":778,"title":"problem on map lazy fields","user":{"login":"alireza-hanifi","id":6841658,"avatar_url":"https://avatars.githubusercontent.com/u/6841658?v=3","gravatar_id":"","url":"https://api.github.com/users/alireza-hanifi","html_url":"https://github.com/alireza-hanifi","followers_url":"https://api.github.com/users/alireza-hanifi/followers","following_url":"https://api.github.com/users/alireza-hanifi/following{/other_user}","gists_url":"https://api.github.com/users/alireza-hanifi/gists{/gist_id}","starred_url":"https://api.github.com/users/alireza-hanifi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alireza-hanifi/subscriptions","organizations_url":"https://api.github.com/users/alireza-hanifi/orgs","repos_url":"https://api.github.com/users/alireza-hanifi/repos","events_url":"https://api.github.com/users/alireza-hanifi/events{/privacy}","received_events_url":"https://api.github.com/users/alireza-hanifi/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2016-03-12T13:43:07Z","updated_at":"2016-04-12T18:43:20Z","closed_at":null,"body":"i don't want to fetch the lazy fields on mapping process.\r\ni have added a field to Mapping Annotation titled as \"hiberanteLazy\".\r\nwhen it is true, the framework checks whether  the field is loaded or not. if it is not loaded, the mapper won't fetch it.\r\n\r\nif you approve this issue, i could commit the changes.\r\nthank you. 😉"},"comment":{"url":"https://api.github.com/repos/mapstruct/mapstruct/issues/comments/209048276","html_url":"https://github.com/mapstruct/mapstruct/issues/778#issuecomment-209048276","issue_url":"https://api.github.com/repos/mapstruct/mapstruct/issues/778","id":209048276,"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-04-12T18:43:20Z","updated_at":"2016-04-12T18:43:20Z","body":"@alireza-hanifi first of all thanks for your pull-request and your offer to contribute that code.\r\n\r\nI'm still not very found of the feature and the use case, though, for the following reasons:\r\n* The feature itself addresses a very specific technology (Hibernate), which we'd like to avoid.\r\n* Plus, leaving out properties based on them being (already) loaded or not should really really be avoided.\r\nLazy loads can be triggered in Hibernate through various means and by design that is supposed to be transparent for the user. For example working on two instances of the same entity class (in one session) could lead to funny effects if you access a collection on the first instance, triggering a lazy load not only on that instance but also on the other instance (if you use the great batch-fetching feature).\r\nThere are just a lot of side effects that can influence the outcome of your mapping. The user of the DTO then can't trust any of the information there, which basically makes the existence of that DTO class obsolte and I'd see that as a flaw in the design of the API / the provided DTOs. That's not something that we should advertise or even explicitlly support.\r\nInstead, what we always recommend in such cases is the usage of specific DTOs, tailored to the needs of the use case at hand. If the user (caller) needs to access a property (e.g. a list of addresses), then it should be part of the DTO and it should always be populated - even if it has to be lazy-loaded. But if the caller doesn't need that information and you find out that the overhead is noticable, then provide an alternative *slim* DTO that doesn't contain the address list property. To the user it is always clear then that there won't be any addresses available in that DTO.\r\n\r\nSo unless @gunnarmorling or @sjaakd see this differently, I'm pretty sure that we won't add this particular feature.\r\n\r\nHowever, as I wrote in #788, I see that there is demand for handling that kind of problem space (skip mapping of individual properties based on some custom logic), so we should think about making the API more approachable to customize the mapping code by dropping in some custom implementations of SPI's that we provide. Theoretically, it's already possible today to add another jar to the processor classpath and enhance the code using our existing APIs, but it requires some in-deph knowledge and it's harder than necessary because lots of our internal model is immutable - and thus harder to customize/decorate. That's something we should definitely work on. It would allow you to do your thing without us having to like it or having us to understand your reasons (which I'm sure you have)... :grinning:\r\n\r\nIs that something you feel could work for you?"}}