Validate if the @AggregateIdentifier field implements toString() function
See original GitHub issueWhen instantiating the meta-model of the aggregate, more specifically on retrieving the @AggregateIdentifier
annotated field, we should verify that the annotated parameter implements a more precise toString()
function than the default Object#toString()
function.
This enforces users to some extent to ensure that the identifier they created returns a reasonable String
version of their identifier.
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
How to tell if an object implements a method like toString()?
The best I have found is by using java.lang.Class.getDeclaredMethod(String,Class<?>...) and calling it on the object's class hierarchy like ...
Read more >Command Model - Axon Reference Guide
An Aggregate Root must declare a field that contains the Aggregate identifier. This identifier must be initialized at the latest when the first...
Read more >A Guide to the Axon Framework - Baeldung
In this article, we'll be looking at Axon and how it helps us implement applications with CQRS (Command Query Responsibility Segregation) ...
Read more >Event Sourcing with Spring Boot and Axon | Novatec
In this blog post I want to give an example on how to implement an event ... and contain a field with the...
Read more >Spring Boot and Axon CQRS - LinkedIn
apply() method. 5. EventSourcing Handlers. The EventSourcing handler is a function that is called when an aggregate is sourced from its events.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I would consider both to be fine, @vab2048. Axon is not biased to the exact format of the
toString()
result, as long as it isn’t theObject#toString()
method which is being used. Using anUUID
is definitely recommended; appending the type might be useful if you would want to reuse theUUID
between distinct aggregate/entities.So:
No it does not, both would be fine.
I have come across this exception when testing my aggregates.
What exactly would constitute good practice for the implementation of toString?
Consider the following two:
PortfolioId(id=bfb21d6e-7587-4dc4-8dbe-3ad4f3d758b5)
bfb21d6e-7587-4dc4-8dbe-3ad4f3d758b5
The first is a default toString as would be implemented by lombok. The second a custom toString which just returns the id.
Does it matter which one is used?