Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: Could there be an annotation to ignore bean fields from mapping? #209

Open
balachandra opened this issue Feb 11, 2020 · 0 comments

Comments

@balachandra
Copy link

Scenario:

if i want to exclude certain common fields across beans, at present, i have to write the following on the mapper

@Mapper(withIgnoreFields = {"age", "Person.indices", "fr.xebia.selma.Person.tags"})

But if the properties are common across beans then it becomes boilerplate to do this across mappers

e.g.

Common entities/beans

User { } 
Employer { }

Beans that has refs to the common entities

Work {
    @MapperIgnore
    private User user;
    @MapperIgnore
    private Employer employer;
    private String name;
}

WorkDto {
    private String name;
}

Time {
    @MapperIgnore
    private User user;
    @MapperIgnore
    private Employer employer;
    private LocalDateTime startTime;
    private LocalDateTime endTime;
}
TimeDto {
    private LocalDateTime startTime;
    private LocalDateTime endTime;
}

Using an annotation at bean field level will help avoid additional need to ignore these fields on each mapper and looks clean. Thoughts on implementing an annotation that ignores the common fields ?

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

No branches or pull requests

1 participant