Skip to content

How to render SQL using NamingStrategies.toLower() #2130

@dschulten

Description

@dschulten

NamingStrategies has a toLower() method to create a RenderNamingStrategy that applies toLower to table and column names, but I cannot find out how to activate it.

The RenderContextFactory has a setNamingStrategy Method where I could set NamingStrategies.toLower(), but I cannot find out how to tweak the RenderContextFactory - I tried to provide my own instance in an @Bean Configuration, but Spring Boot doesn't pick up my reconfigured RenderContextFactory.

Background: I use Postgres in Prod, but H2 during development, and both have different opinions about table and column naming.
Hence when running H2, I get this error:

Table "MANDANT" not found (candidates are: "mandant"); SQL statement:
SELECT "MANDANT"."ID" AS "ID", "MANDANT"."SCHLUESSEL" AS "SCHLUESSEL", "MANDANT"."BEZEICHNUNG" AS "BEZEICHNUNG" FROM "MANDANT" WHERE "MANDANT"."SCHLUESSEL" = ? [42103-232]

I managed to influence the RenderNamingStrategy by setting the dialect to JdbcPostgresDialect.INSTANCE in AbstractJdbcConfiguration, but that has unintended consequences elsewhere, e.g. when working with columns of Array type in H2.

Metadata

Metadata

Assignees

Labels

for: stackoverflowA question that's better suited to stackoverflow.com

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions