GiftCard Demo App and JpaEventStorageEngine for EmbeddedEventStore

Hi ,
I am new to Axon. I try to use JpaEventStorageEngine and EmbeddedEventStore in Axon Demo GiftCard App.What I must change in pom/properties/java code (step by step) for MySql or Postgress as EventStore?
Can anybody help me by samle?

Hello and welcome Max,

I don’t have a sample handy (maybe someone does) but I wander if you have tried to follow the docs. It is almost a step by step explanation of the things you have to configure. In case you haven’t tried that, please do. If you did tried it (or when you do) and you faced issues, or there is something unclear or missing, … do not hesitate to report/ask here.

Thanks Milen,
yes I tryed doc at reference
and I have this error:

    2021-01-22 12:47:45.664  WARN 16900 --- [ftcard.query]-0] o.a.e.TrackingEventProcessor             : Fetch Segments for Processor 'io.axoniq.demo.giftcard.query' failed: org.hibernate.hql.internal.ast.QuerySyntaxException: DomainEventEntry is not mapped [SELECT MIN(e.globalIndex) - 1 FROM DomainEventEntry e]. Preparing for retry in 32s
Hibernate: select tokenentry0_.segment as col_0_0_ from token_entry tokenentry0_ where tokenentry0_.processor_name=? order by tokenentry0_.segment ASC

My pom:

        <!-- Axon -->



package io.axoniq.demo.giftcard.command;

import org.axonframework.common.jdbc.PersistenceExceptionResolver;
import org.axonframework.common.jpa.EntityManagerProvider;
import org.axonframework.common.transaction.TransactionManager;
import org.axonframework.eventsourcing.eventstore.EmbeddedEventStore;
import org.axonframework.eventsourcing.eventstore.EventStorageEngine;
import org.axonframework.eventsourcing.eventstore.EventStore;
import org.axonframework.eventsourcing.eventstore.jpa.JpaEventStorageEngine;
import org.axonframework.serialization.Serializer;
import org.axonframework.spring.config.AxonConfiguration;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

public class EventStoreConfig {

    public EmbeddedEventStore eventStore(EventStorageEngine storageEngine, AxonConfiguration configuration) {
        return EmbeddedEventStore.builder()
                .messageMonitor(configuration.messageMonitor(EventStore.class, "eventStore"))

    public EventStorageEngine storageEngine(Serializer defaultSerializer,
                                            PersistenceExceptionResolver persistenceExceptionResolver,
                                            @Qualifier("eventSerializer") Serializer eventSerializer,
                                            AxonConfiguration configuration,
                                            EntityManagerProvider entityManagerProvider,
                                            TransactionManager transactionManager) {
        return JpaEventStorageEngine.builder()

What wrong I do? I must simply delete class EventStoreConfig?

Seems like your JPA is not properly configured.
Have you seen this post: DomainEventEntry is not mapped

I new member, and I can’t put my or picture into replay. :frowning:

I delete config java class and get state and events in one persistent JPA.

Now I think about them - how I can put events separatly from state.
I want make one persistent JPA for EvetnStore and second persistent JPA for sate in GiftCard Demo App.

To be honest with you, I don’t understand what do you mean.
Event store is where all the events are stored. Leaving aside segments for a moment, all apps connected to the same event store will be able to store/retrieve events from it. In that sense Event store IS the database fro events. It can be backed by database but it does not have to. For example AxonServer is another event store.

So your statement

I want make one persistent JPA for EvetnStore and second persistent JPA for sate in GiftCard Demo

does not make sense for event sourced aggregate(s) in GiftCard demo. The only thing you need to configure is the event store and the state of the aggregate(s) will be constructed from those events when needed.

Or do you want to change GiftCard demo to use State Stored Aggregate instead of event sourced one?

In GiftCard App I want to split on 2 JPA store.
First for event sourced aggregate as domain_event_entry (eventStore persistence JPA) and second store for data class CardSummary (state projection persistence JPA).

Ah the projections you mean. That makes sense now. I got confused by the word “state” as projections are not considered “state” in event sourced systems. Projections are just some specific view of some parts of the system useful for querying purposes. The state however is always calculated from the events.

For that I believe it’s sufficient to have 2 different persistence units. For example dedicated one for the event store and default one for the projections.

The JpaEventStorageEngine docs (see the link in my first response) contains examples how to use specific persistence context for the event store.

Here is example config:

<persistence xmlns="" version="1.0">
    <persistence-unit name="eventStorePersistenceUnit" transaction-type="RESOURCE_LOCAL"> (1)
        <class>org...eventstore.jpa.DomainEventEntry</class> (2)

and an EntityManagerProvider that provides EntityManager for that unit:

public class MyEntityManagerProvider implements EntityManagerProvider {

    private EntityManager entityManager;

    public EntityManager getEntityManager() {
        return entityManager;

    @PersistenceContext(unitName = "eventStorePersistenceUnit")
    public void setEntityManager(EntityManager entityManager) {
        this.entityManager = entityManager;

Have you tried that?

  1. persistence.xml

But I see all tables in one schema in my-db database:

What wrong I do?