How to get table names in snake case with Quarkus and Panache

Viewed 1013

I have Java entities with a composite camel case name, e.g., EmployeeProject.

I need to map those entities on tables with snake case names, e.g., employee_project, instead of the default used by Quarkus/Panache, e.g., employeeproject.

I know I can set a custom table name with @Entity(name = "employee_project") but I was wondering if there is some sort of application property which do the same work for me.

2 Answers

If using Christian's answer and implementing a SnakeCaseNamingStrategy (see here), you can use application.properties to configure it in Quarkus. This way you don't have to go through the configuring hibernate in persistence.xml.

quarkus.hibernate-orm.physical-naming-strategy=com.example.SnakeCaseNamingStrategy
Related