Skip to content

add interceptor for the mapping engine resolveSourceValue method retu…#644

Open
kamilors wants to merge 1 commit into
modelmapper:masterfrom
kamilors:master
Open

add interceptor for the mapping engine resolveSourceValue method retu…#644
kamilors wants to merge 1 commit into
modelmapper:masterfrom
kamilors:master

Conversation

@kamilors
Copy link
Copy Markdown

@kamilors kamilors commented Oct 20, 2021

Probably when hibernate session is used, it creates empty hibernate proxy instance for lazy loaded fields. Therefore, it causes lazy load exception or n+1 select problem when using model mapper deep copying.

Example usage for intercepter:

mapper.getConfiguration().setResolveSourceValueInterceptor(source -> {
    if (emFactory.getPersistenceUnitUtil().isLoaded(source)) {
            return source;
    }
    return null; // return null when hibernate field is not fetch from database (lazy loading)
});

The problem solution has been provided based on the issue here #97.

@nejcsilc
Copy link
Copy Markdown

👍

@mvishnumohan
Copy link
Copy Markdown

Any plan to merge this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants