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

FluentAssembler overrides generated aggregate identity #91

Open
Magador opened this issue Jun 26, 2017 · 4 comments
Open

FluentAssembler overrides generated aggregate identity #91

Magador opened this issue Jun 26, 2017 · 4 comments

Comments

@Magador
Copy link

Magador commented Jun 26, 2017

Suppose a Person aggregate and DTO :

public class Person extends BaseAggregateRoot<UUID> {
    @Identity(handler = UUIDHandler.class)
    private UUID id;
    private String name;
}
public class PersonDTO {
    private UUID id;
    private String name;
}

In a standard workflow, we would create a PersonDTO without id in a interface and send it to the server. The server would then merge it into a freshly created aggregate :

fluentAssembler.merge(personDTO).into(Person.class).fromFactory();

The default factory will create a UUID as identity with the IdentityService, but when the actual mapping will happen, the null value of the DTO's id will override the generated id of the aggregate.

One workaround is to call the identity service again after the merge.

@adrienlauer
Copy link
Member

The best solution, I think, is to configure ModelMapper to ignore nulls:

modelMapper.getConfiguration().setPropertyCondition(Conditions.isNotNull());

I think that this behavior is highly desirable and should be the default. I will take this into account when making ModelMapper assemblers configurable in business framework 4.0.

@maneesh-innani
Copy link

Apart from model mapper, can we add support for other mapping tools like dozer?

@maneesh-innani
Copy link

Probably we want also to integrate one example , showing directly working with UML stereotypes, like in enterprise architect?

@adrienlauer
Copy link
Member

ModelMapper was refactored as an add-on (https://search.maven.org/artifact/org.seedstack.addons.modelmapper/modelmapper/1.0.0/jar) so the same can be done for Dozer, quite easily.

I'm not having much time to work on this but if you have some time to contribute it, I would be delighted. I can setup the repository and the release process for the new add-on if you want to start on 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

No branches or pull requests

3 participants