Axon Framework在Oracle数据库中的表名 + 使用Spring JPA进行表自动生成

huangapple go评论74阅读模式
英文:

Axon Framework tables names with Oracle + Spring jpa table autogeneration

问题

我正在使用不带Axon Server的Axon Framework 4.1,结合Oracle 12.1和Spring Boot Jpa 2.3.0。

在应用程序启动时,我使用以下属性通过Hibernate来生成所有的表,包括Axon的表:spring.jpa.hibernate.ddl-auto=create。结果,我得到的表名格式为DOMAIN_EVENT_ENTRYTOKEN_ENTRY等等。
在此之后,当我发送一个命令时,我收到以下错误消息:无法持久化聚合[2]在序列[0]上的事件

我认为这是因为Axon正在搜索名为DOMAINEVENTENTRY的表,但找不到它,从而导致错误消息。当我将DOMAIN_EVENT_ENTRY表重命名为DOMAINEVENTENTRY后,一切都开始正常工作。

如果我猜得没错的话,这就是问题所在。但另一方面,我曾经在H2数据库上使用过Axon,并且在表名为DOMAIN_EVENT_ENTRY的情况下也能正常工作,所以我猜这可能是一个Oracle特定的问题?

因此,我的问题是:如何配置Axon的表名,以便在不进行任何修改的情况下,生成具有正确表名的表结构。

另外,在这种情况下,提供更详细的错误消息会很有帮助。为什么我的事件无法持久化。

与此问题相关的属性设置:

hibernate.dialect=org.hibernate.dialect.Oracle12cDialect
spring.jpa.hibernate.ddl-auto=create
spring.jpa.generate-ddl=true
spring.datasource.url=
spring.datasource.username=
spring.datasource.password=
spring.datasource.driver.class=oracle.jdbc.driver.OracleDriver

谢谢,
Mate

英文:

I am using Axon Framework 4.1 (without Axon Server) with Oracle 12.1 and Spring Boot Jpa 2.3.0

When the application starts I am using hibernate via this property spring.jpa.hibernate.ddl-auto=create to generate all my tables including Axon's tables. As a result I got the names in this format DOMAIN_EVENT_ENTRY, TOKEN_ENTRY etc..
After that, when I send a command, I got the following error message: An event for aggregate [2] at sequence [0] could not be persisted.

I think this is because Axon searching for the table with the name: DOMAINEVENTENTRY and not finding it and I got the error message. When I renamed DOMAIN_EVENT_ENTRY table to DOMAINEVENTENTRY everything started working well.

If I guess well this is the problem. But on the other hand I used Axon with H2 and it worked with the name DOMAIN_EVENT_ENTRY, so I guess its an Oracle specific issue?

So my question is how can I configure the Axon tables name to generate the tables in the right name without hacking.

And think it would be good in this case a more detailed error message. Why my event can't be persisted.

My properties related with the question:

hibernate.dialect=org.hibernate.dialect.Oracle12cDialect
spring.jpa.hibernate.ddl-auto=create
spring.jpa.generate-ddl=true
spring.datasource.url=
spring.datasource.username=
spring.datasource.password=
spring.datasource.driver.class=oracle.jdbc.driver.OracleDriver

Thanks,
Mate

答案1

得分: 1

更新

以下是答案:
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
这将以如下风格创建表:DOMAINEVENTENTRY 等等。

英文:

UPDATE

Here is the answer:

spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl

This create the tables in this style: DOMAINEVENTENTRY etc..

huangapple
  • 本文由 发表于 2020年8月26日 16:46:43
  • 转载请务必保留本文链接:https://go.coder-hub.com/63593915.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定