spring-modulith icon indicating copy to clipboard operation
spring-modulith copied to clipboard

Overriding event table name

Open tuuka opened this issue 1 year ago • 3 comments
trafficstars

Hello. Is there any way to override the name of the event_publication table to record events? Prior to version 1.1.0, it was possible to create own repository that extends EventPublicationRepository and, accordingly, use your own entity, which is mapped to a table with the desired name. In 1.1.0, the JpaEventPublicationRepository repository became package private same as EventPublicationRepository, which made it impossible to override/reimplement it in any simple way.

tuuka avatar Dec 18 '23 08:12 tuuka

You can add a file to overwrite the entity mapping metadata.

example src/main/resources/META-INF/orm.xml

<?xml version="1.0" encoding="UTF-8"?>
<entity-mappings xmlns="http://xmlns.jcp.org/xml/ns/persistence/orm"
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                 xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence/orm
                                     http://xmlns.jcp.org/xml/ns/persistence/orm_2_2.xsd"
                 version="2.2">
<package>org.springframework.modulith.events.jpa</package>
    <entity class="JpaEventPublication">
    <table name="blablub" />
    </entity>
</entity-mappings>

der-ambi avatar Feb 01 '24 21:02 der-ambi

Thank you. But I thought it would be very good if there were no additional xml.. Some props may be...

tuuka avatar Feb 02 '24 11:02 tuuka

Yes I would be nice to be able to customize table name or schema (my use case) via a property

mikomatic avatar Jun 23 '24 08:06 mikomatic