Enable auto-configuration of GenericJpaRepository with axon-spring #234

Open
mark-verebelyi opened this Issue Jan 12, 2017 · 2 comments

Projects

None yet

3 participants

@mark-verebelyi

Currently SpringAxonAutoConfiguration configures exclusively EventSourcingRepositories for Aggregates. There is a possibility to reference a named repository, but it must be created manually for every aggregate. It would be nice to have an option to choose the type of aggregate (event-sourced vs "normal") and have the framework configure the proper repository implementation automatically.

@abuijze abuijze added this to the Release 3.1 milestone Jan 12, 2017
@abuijze abuijze added the Enhancement label Jan 12, 2017
@redhead
redhead commented Feb 12, 2017

+1
I already did something similar using annotations. Basically, the aggregate is annotated with @EventSourced annotation and is picked up when creating Spring context and registers an event sourcing repository bean for that aggregate automatically. Usage looks like this:

@EventSourced
@Aggregate
public class UserAggregate { ... }

You can see the implementation of that automation here (feel free to get inspired): https://gist.github.com/redhead/13e125f2660370d3692bf43892c0cec1

@abuijze
Member
abuijze commented Feb 20, 2017

I suggest an automatic check for a JPA @Entity annotation. If found, it is stored using the Standard way (repository created if not already defined). Otherwise, if @EventSourcingHandler annotations are found, it is stored using an EventSourcingRepository.

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