[axonframework] Statebased Aggregates and SpringContextParameterResolverFactoryBuilder

Hi Marco,

did you “manually” configure the JPA Repository? If so, can you share your configuration?

Kind regards,

Hi Allard

First I didn’t manually configure it. This lead to the problem as the needed resolver SpringBeanParameterResolverFactory was missing.

`

@Bean
public GenericJpaRepository nodeRepository(EntityManagerProvider entityManagerProvider, EventBus eventBus) {
return new GenericJpaRepository(entityManagerProvider, Node.class, eventBus, (id) -> NodeId.of(id));
}

`

Today I manually configured the resolver. Now it works. But I expected that it should work out of the box.

`

@Bean
public GenericJpaRepository nodeRepository(EntityManagerProvider entityManagerProvider, EventBus eventBus, ApplicationContext applicationContext) {

return new GenericJpaRepository(entityManagerProvider, Node.class, eventBus,
NullLockFactory.INSTANCE, new MultiParameterResolverFactory(new DefaultParameterResolverFactory(), new SpringBeanParameterResolverFactory(applicationContext)), identConverter);

}

`

Cheers
Marco

P.S: In my post I was referencing SpringContextParameterResolverFactoryBuilder. This was wrong. Correct would have been SpringBeanParameterResolverFactory…

Hi Marco,

instead of configuring the ParameterResolverFactory, have it injected into your bean method. Axon configures an instance in the application context that automatically provides support for all possible parameters.

Also, simply adding JPA’s @Entity annotation will have Axon configure the JPARepository for you automatically.

Cheers,

Allard Buijze

CTO