I stumbled upon a strange error today. One of my Java Persistence Application programming interface (JPA) entities in Spring Boot application is not working. I tracked the problem down to a single column:
@javax.persistence.Column(name = "NameWrittenInPascalCase")
java.lang.String c;
When I checked the Structured Query Language (SQL) query which Spring Boot/Hibernate generates I discovered the problem. It seams that Spring Boot or Hibernate converts the NameWrittenInPascalCase
into name_written_in_pascal_case
(just written in snake case). (In database, of course, my column name is written in PascalCase).
For gods sake, why?
And how to prevent it from doing so?
If you need aditional info, I use Spring Boot version 2.5.7.
in your project application.properties
file set the naming strategy:
spring.jpa.hibernate.naming-strategy=org.hibernate.cfg.EJB3NamingStrategy
Default value is org.springframework.boot.orm.jpa.SpringNamingStrategy
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.