Skip to content

Hibernate lazy loading aware mapping #2776

@reitzmichnicht

Description

@reitzmichnicht

I think a common problem when using mapstruct for mapping entities to DTOs is that it might produce lazy loading of relations. So in case of different entity fetch graphs you would need different mapping methods that explicitly ignore the lazy loaded stuff and only map the eager loaded properties.
Luckily Hibernate allows to determine on its generated proxy entities if a property is eager or lazy loaded. So the idea is to extend mapstruct with a strategy to only map eager loaded properties by default.

I would be happy to contribute this, the question is where is the best place to extend this behaviour. To be honest the mapstruct architecture doesn't look very extendable for such use cases to provide custom mapping strategies.

Kind regards,
Michael

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions