Partner – Moderne – NPI EA (cat=Spring Boot)
announcement - icon

Refactor Java code safely — and automatically — with OpenRewrite.

Refactoring big codebases by hand is slow, risky, and easy to put off. That’s where OpenRewrite comes in. The open-source framework for large-scale, automated code transformations helps teams modernize safely and consistently.

Each month, the creators and maintainers of OpenRewrite at Moderne run live, hands-on training sessions — one for newcomers and one for experienced users. You’ll see how recipes work, how to apply them across projects, and how to modernize code with confidence.

Join the next session, bring your questions, and learn how to automate the kind of work that usually eats your sprint time.

Course – Black Friday 2026 – NPI EA – main – before_post_content
announcement - icon

Yes, we're now running our Black Friday Sale. All Courses are 33% off until 1st December, 2026 at 17:00 Romania time:

>> EXPLORE ACCESS NOW

Course – Black Friday 2026 – NPI – main – before_post_content
announcement - icon

Yes, we're now running our Black Friday Sale. All Courses are 33% off until 1st December, 2026 at 17:00 Romania time:

>> EXPLORE ACCESS NOW

1. Introduction

In this brief tutorial, we’ll see how to use the Hibernate naming strategies in a Spring Boot application.

2. Maven Dependencies

If we begin with a Maven-based Spring Boot application, and we are happy to embrace Spring Data, then we just need to add the Spring Data JPA dependency:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>

Also, we need a database, so we’ll use the in-memory database H2:

<dependency>
    <groupId>com.h2database</groupId>
    <artifactId>h2</artifactId>
    <scope>runtime</scope>
</dependency>

The Spring Data JPA dependency brings in the Hibernate dependencies for us.

3. Spring Boot Naming Strategies

Hibernate maps field names using a physical strategy and an implicit strategy. We previously talked about how to work with the naming strategies in this tutorial.

And, Spring Boot, provides defaults for both:

  • spring.jpa.hibernate.naming.physical-strategy defaults to org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy, and
  • spring.jpa.hibernate.naming.implicit-strategy defaults to org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy

We can override these values, but by default, these will:

  • Replace dots with underscores
  • Change camel case to snake case, and
  • Lower-case table names

So, for example, an AddressBook entity would be created as the address_book table.

4. Strategies in Action

If we create an Account entity:

@Entity
public class Account {
    @Id 
    private Long id;
    private String defaultEmail;
}

And then turn on some SQL debugging in our properties file:

hibernate.show_sql: true

At startup, we’ll see the following create statement in our logs:

Hibernate: create table account (id bigint not null, default_email varchar(255))

As we can see, the fields use snake case and are lower cased, following the Spring conventions.

And remember that we don’t need to specify the physical-strategy or the implicit-strategy properties in this case since we are accepting the defaults.

5. Customizing Strategies

So, let’s say that we want to use the strategies from JPA 1.0.

We only need to indicate it in our properties file:

spring:
  jpa:
    hibernate:
      naming:
        physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
        implicit-strategy: org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyJpaImpl

Or, expose them as @Beans:

@Bean
public PhysicalNamingStrategy physical() {
    return new PhysicalNamingStrategyStandardImpl();
}

@Bean
public ImplicitNamingStrategy implicit() {
    return new ImplicitNamingStrategyLegacyJpaImpl();
}

Either way, if we run our example with these changes, we’ll see a slightly different DDL statement:

Hibernate: create table Account (id bigint not null, defaultEmail varchar(255), primary key (id))

As we can see, this time these strategies follow the JPA 1.0’s naming convention.

Now, if we wanted to use the JPA 2.0 naming rules we’d need to set ImplicitNamingStrategyJpaCompliantImpl as our implicit strategy.

6. Conclusion

In this tutorial, we saw how Spring Boot applies naming strategies to Hibernate’s query generator, and we also saw how to customize those strategies.

The code backing this article is available on GitHub. Once you're logged in as a Baeldung Pro Member, start learning and coding on the project.
Partner – Moderne – NPI EA (tag=Refactoring)
announcement - icon

Modern Java teams move fast — but codebases don’t always keep up. Frameworks change, dependencies drift, and tech debt builds until it starts to drag on delivery. OpenRewrite was built to fix that: an open-source refactoring engine that automates repetitive code changes while keeping developer intent intact.

The monthly training series, led by the creators and maintainers of OpenRewrite at Moderne, walks through real-world migrations and modernization patterns. Whether you’re new to recipes or ready to write your own, you’ll learn practical ways to refactor safely and at scale.

If you’ve ever wished refactoring felt as natural — and as fast — as writing code, this is a good place to start.

Course – Black Friday 2026 – NPI EA – main – after_post_content

announcement - icon

Yes, we're now running our Black Friday Sale. All Courses are 33% off until 1st December, 2026 at 17:00 Romania time:

>> EXPLORE ACCESS NOW

Course – Black Friday 2026 – NPI – main – after_post_content

announcement - icon

Yes, we're now running our Black Friday Sale. All Courses are 33% off until 1st December, 2026 at 17:00 Romania time:

>> EXPLORE ACCESS NOW