"SagaEntry is not mapped"

AXON, Spring Boot and JPA are giving me a hard time. I'm new to most of this.

org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext

...
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name
'sagaStore' defined in class path resource [org/axonframework/springboot/autoconfig/JpaAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.axonframework.modelling.saga.repository.jpa.JpaSagaStore]: Factory method 'sagaStore' threw exception; nested exception is java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException:
  *SagaEntry is not mapped* [SELECT new org.axonframework.modelling.saga.repository.jpa.SerializedSaga(se.serializedSaga, se.sagaType, se.revision) FROM SagaEntry se WHERE se.sagaId = :sagaId]
  at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:645)

It fails with the same error, whether with @EntityScan and/or @RegisterDefaultEntities, or without either. For those two annotations I tried them with most of my package names plus

"org.axonframework.eventsourcing.eventstore.jpa",
"org.axonframework.modelling.saga.repository.jpa", // I also tried org.axonframework.eventhandling.saga.repository.jpa, though apparently it's not to be used since AXON 4.0?
"org.axonframework.eventhandling.tokenstore.jpa".

I've tried that with org.axonframework:axon-test and
org.axonframework:axon-spring-boot-starter 4.2 and 4.2.1.

Please advise.

Also, my code doesn’t mention (and doesn’t need) any “saga”. What can involve Sagas as a side effect?

Hi Peter,

I had to check the code to find out why the SagaEntry would be used so “aggressively”. It seems that there is an “optimization” that kicks in when the JpaSagaRepository is created, which registers a number of named queries.
I don’t see why adding the “org.axonframework.modelling.saga.repository.jpa” package to @EntityScan wouldn’t resolve the issue.

Note that the @RegisterDefaultEntities is an Axon-internal annotation, that just registers a few default locations with Spring Boot. These default locations are ignored once Spring Boot detects one or more @EntityScan annotations on your configuration.

Do you have any specific Hibernate configuration in your Spring Contexts?

Cheers,