JPA column with incorrect underscore

spring jpa rename column
jpa referring to multiple physical column names
jpa field naming convention
hibernate column name
spring boot add column
spring data entity field name

I use JPA for database access and annotated every column with the correct name. Now if I execute a query (e.g. findAll()) it returns

Unknown column 'program0_.program_id' in 'field list'

The error message is correct program_id is unknown because the real name is programId.

Models: Program

  @Table(name = "programs")
  public class Program implements Serializable {
          @GeneratedValue(strategy = GenerationType.IDENTITY)
          @Basic(optional = false)
          @Column(name = "programId")
          private Long programId;
                  name = "programlabels",
                  joinColumns = {
                    @JoinColumn(name = "program", referencedColumnName = "programId")},
                  inverseJoinColumns = {
                    @JoinColumn(name = "label", referencedColumnName = "labelId")})
          private Collection<Label> labels;


@Table(name = "labels")
public class Label implements Serializable {
  @Basic(optional = false)
  @Size(min = 1, max = 100)
  @Column(name = "labelId")
  private String labelId;  


select program0_.program_id as program_1_5_, ...

Is there a reason why JPA changes "programId" to "program_id" or am I missing any configuration?


Edit: Oh sorry forgot to add query code/information.

I use the Spring Data's JpaRepository interface and tried the findAll() query.

public interface ProgramRepository extends JpaRepository<Program, Long> {}

How to map camelCase properties to snake_case column names , Learn how to map CameCase entity properties like phoneNumber to you could achieve the same goal with the name attribute of JPA @Column annotation, the default EAGER fetching strategy is almost always a bad idea. spring jpa specify column name (6) I solved this error by renaming field to the name without underscore. @Column(name = "municipal_id", nullable = false) private Integer municipalId; // <-- field was renamed I am using spring-data-jpa on a spring webmvc project.

spring.jpa.hibernate.naming.strategy is not a supported property for Spring JPA implementation using Hibernate 5.

Use the below property in


@Column with name attribute not working property on entities , @Column(name = "aAa") -> sql query uses column "a_aa" -> incorrect. When I put spring.jpa.hibernate.naming_strategy=org.hibernate.cfg. For one, we have to look up the names of entity attributes. And, in case a column name is changed later in the project lifecycle, we have to refactor each query where the name is being used. The JPA Metamodel was introduced by the community to avoid these drawbacks and provide static access to the metadata of the managed entity classes. 3

Were able to map

@Column(name = "PersonFullName")

private String PersonFullName;

to the database table column name "PersonFullName" without the underscore.

The below worked for me. Add this in the application settings and then use @Column to specify the physical database column name for the model's property.

@Column(name = "PersonFullName")


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

Hibernate Field Naming with Spring Boot, jpa.hibernate.SpringImplicitNamingStrategy. We can override these values, but by default, these will: Replace dots with underscores; Change  For example, we may want to use camel case names in our Java code, but we want to use underscore separated names for our actual table and column names in the database. Now, we could use a combination of annotations and a custom ImplicitNamingStrategy to map these names correctly, but Hibernate 5 provides the PhysicalNamingStrategy as a way to

use below in


JPA column with incorrect underscore, I use JPA for database access and annotated every column with the correct name​. Now if I execute a query (e.g. findAll() ) it returns. Unknown column  @Column(name = "aa")-> sql query uses column "aa" -> correct @Column(name = "aA")-> sql query uses column "aa" -> incorrect @Column(name = "aAa")-> sql query uses column "a_aa" -> incorrect; When I put spring.jpa.hibernate.naming_strategy=org.hibernate.cfg.EJB3NamingStrategy into, then everything works properly. But I don

2. JPA Entity Configuration, Using the ImprovedNamingStrategy in your JPA persistence.xml can give better translation from camel case classes and field names to standard underscore  In this article, you are going to learn how to map cameCase entity properties (e.g. phoneNumber) to snake_case column names (e.g. phone_number) using a Hibernate naming strategy. While you could achieve the same goal with the name attribute of JPA @Column annotation, it’s much more convenient to use a custom Hibernate strategy to apply this

Hibernate Tips: How to escape table and column names, It's also supported by all other JPA annotations that allow you to define a database identifier. These are: @EntityResult; @FieldResult; @ColumnResult; @​  Introduction. In this article, we are going to see how you can escape SQL reserved keywords with JPA and Hibernate. I decided to write this article because I keep on seeing this problem on the Hibernate forum or StackOverflow.

Different Hibernate Naming Strategy, Hibernate uses these strategy to map the java entity and attribute name accepts default, jpa, legacy-hbm, legacy-jpa and component-path. ( separator )​.append( part ); if ( firstPass ) { firstPass = false; separator = "_"; } } return joined. by underscores and camel casing is replaced by underscores and all  The following example will show how to use JPA in a real-world scenario. You’ve been asked to quickly mock up a simple blog application; here are your constraints: All database table names are uppercase, words separated by an underscore (“_”) All table columns must start with the table name, or its initials

  • Check this
  • I may be wrong, but I think that doesn't help me, because the problem is that JPA uses the wrong column name, regardless of what I see in the console. What I have seen the column names are the same in both outputs.
  • Your problem may be related with this one: spring-boot-jpa-column-name-annotation-ignored
  • Thanks that is the same issue. I added a naming strategy to the configuration and now it works. If you want to add it as answer you get some useless internet points.