Reputation: 2579
I have two schemas in my database and both share tables with the same names. In order to not have naming conflicts in generated code, I want to prefix all names with the appropriate schema name.
I made it work for class names by overriding getJavaClassName
of DefaultGeneratorStrategy
however I could not find a fitting override that is responsible for the table references in tables.references.Tables.kt
.
Upvotes: 1
Views: 76
Reputation: 2579
I managed to solve my problem by overriding getJavaIdentifier
of DefaultGeneratorStrategy
the following way:
override fun getJavaIdentifier(definition: Definition): String {
if (definition is PostgresTableDefinition) {
return "${definition.schema.name.toUppercaseSnakeCase()}_${super.getJavaIdentifier(definition)}"
}
return super.getJavaIdentifier(definition)
}
Upvotes: 1