我正在尝试使用JPA事件存储和mysql数据库实现Axon应用程序。Hibernate正在自动生成所有表,到目前为止工作正常。
我的问题是-我可以替换mysql中AUTO_INCREMENT
列的hibernate_sequence mysql表吗。我想为了做到这一点,我需要修改Axon的源代码,因为我找不到其他可配置的方法来修改域事件或其他实体的注释?
更新
好的,我通过在@Id
中放置新文件来实现,代码如下:
<?xml version="1.0" encoding="UTF-8" ?>
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_2_0.xsd"
version="2.0">
<mapped-superclass class="org.axonframework.eventhandling.AbstractSequencedDomainEventEntry" access="FIELD">
<attributes>
<id name="globalIndex">
<generated-value strategy="IDENTITY"/>
</id>
</attributes>
</mapped-superclass>
<entity class="org.axonframework.modelling.saga.repository.jpa.AssociationValueEntry" access="FIELD">
<attributes>
<id name="id">
<generated-value strategy="IDENTITY"/>
</id>
</attributes>
</entity>
</entity-mappings>
最佳答案
你可以通过代码进行调整,这是真的。
不过,在项目中指定一个orm.xml
文件更简单,对于某些表(我假设场景中的domain_event_entry
表)可以调整某些列。
在那里你应该能够调整序列生成器到你想要的。
希望这有帮助!