In Quarkus, you can configure Hibernate's physical naming strategy using the property quarkus.hibernate-orm.physical-naming-strategy. If you set this property to org.hibernate.boot.model.naming.CamelCaseToUnderscoresNamingStrategy
, Hibernate will convert CamelCase entity names to snake_case table names.
However, if you also specify the table name using the @jakarta.persistence.Table(name = "something") annotation, the annotation will be overridden by the property. This can be confusing because it seems like the annotation should take precedence.
My use case is to apply the naming strategy to all the column props and not the table names. Is there a way to achieve this?
The value in the @Table
annotation - is a logical name. The strategy converts logical names to physical ones, these steps are described here: https://docs.jboss.org/hibernate/orm/6.1/userguide/html_single/Hibernate_User_Guide.html#naming.
You can define your own strategy class extending CamelCaseToUnderscoresNamingStrategy, override the toPhysicalTableName
method, and force it to return the input value without changing.