Unable to override globalIndex by providing custom sequence generator under /META-INF/orm.xml

I’m trying to use custom sequence generator for globalIndex by proving below mapping under /META-INF/orm.xml.

<?xml version="1.0" encoding="UTF-8"?>
<entity-mappings version="1.0" xmlns="http://java.sun.com/xml/ns/persistence/orm">
    <mapped-superclass access="FIELD" metadata-complete="false" class="org.axonframework.eventhandling.AbstractSequencedDomainEventEntry">
        <attributes>
            <id name="globalIndex">
                <generated-value strategy="SEQUENCE" generator="myGenerator"/>
                <sequence-generator name="myGenerator" sequence-name="mySequence"/>
            </id>
        </attributes>
    </mapped-superclass>
</entity-mappings>

But always getting this warning at startup.

org.hibernate.cfg.annotations.reflection.JPAOverriddenAnnotationReader → HHH000207: Property org.axonframework.eventhandling.AbstractSequencedDomainEventEntry.globalIndex not found in class but described in (possible typo error)

Anyone has faced this issue ?

Hi Shubhojit Roy,

Thank you for reaching out to us. After analyzing Hibernate code, I figured out that the warning message you’ve encountered in your application comes from Hibernate’s XML reader, which verifies whether all properties defined in XML mapping are reachable via public accessors.
I assume that in your application, you want to override a sequence generator for the field AbstractSequencedDomainEventEntry#globalIndex. In this case, the warn message is overeager because Hibernate can override the sequence generator without public accessors. You can verify this behavior by lowering the log level for hibernate package. In a Spring Boot based application, you can achieve this by setting the following property:

logging.level.org.hibernate=DEBUG

Then, you can look for the following message in the output:

2021-09-22 14:45:28.896 DEBUG 47686 --- [           main] org.hibernate.cfg.BinderHelper           : #makeIdGenerator(org.hibernate.mapping.SimpleValue([org.hibernate.mapping.Column(global_index)]), globalIndex, org.hibernate.id.enhanced.SequenceStyleGenerator, myGenerator, ...)

If the fourth parameter in the message is your generator name, then Hibernate should use it for the globalIndex.
Please, let us know if you need any more help.

Michal