Skip to content
Advertisement

How to map Hibernate entity fields using camelCase to snake_case (underscore) database identifiers

I have database fields in underscore. I have entity fields in camelcase. I can’t change either of those.

Is there something, maybe a class level annotation I can use to default entity column name annotations to the camelcase equivalent?

for example, I have an entity like this:

JavaScript

I dream of this:

JavaScript

Advertisement

Answer

You can use hibernate’s naming strategy. Such naming strategy class describes how to generate database names for given java names.

See:

naming strategy example

second example

very good oracle naming strategy – it converts camel to underscore convention, and much more

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement