Home > Database > Mysql Tutorial > How to Preserve Table Name Casing with Spring Boot JPA and Hibernate?

How to Preserve Table Name Casing with Spring Boot JPA and Hibernate?

Mary-Kate Olsen
Release: 2024-11-09 08:44:02
Original
204 people have browsed it

How to Preserve Table Name Casing with Spring Boot JPA and Hibernate?

Spring Boot JPA Insertion into Table with Uppercase Name Using Hibernate

Using Spring Boot JPA to insert records into a database, it is important to ensure the table name matches the entity name defined in the code. However, in some cases, the table name may be automatically converted to lowercase by default. This issue can arise when the table's name is declared in uppercase in the database, but the entity mapping in code uses a lowercase version.

To resolve this issue without modifying the MySQL configuration, it is necessary to adjust the Hibernate configuration in the Spring Boot application. By setting the following property in the application.properties file, you can specify the physical naming strategy for Hibernate 5:

spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
Copy after login

This naming strategy preserves the casing of the table name in the database, ensuring that the table name remains uppercase as defined. By making this adjustment, the insertion operations will correctly target the table with the uppercase name, resolving the issue of automatic conversion to lowercase.

The above is the detailed content of How to Preserve Table Name Casing with Spring Boot JPA and Hibernate?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template