Hibernate field naming issue with Spring Boot (naming strategy)

SINCE SPRING-BOOT 1.4

Starting from 1.4, because of the switch to Hibernate 5, the naming strategy has been updated to SpringPhysicalNamingStrategy which should be very close to 1.3 defaults.

See also:


PREVIOUS VERSION

Spring Boot provides the ImprovedNamingStrategy as default naming strategy, which makes Hibernate search for a team_id column (inferred from the int teamId field). As this column doesn’t exist in your table, that’s the cause of the error. From the Hibernate docs:

An improved naming strategy that prefers embedded underscores to mixed case names

You’ve got two options:

  1. Provide the column name explicitly as @Column(name="teamId"). There used to be a bug with this in early Boot versions, not anymore.

  2. Change the naming strategy in the Spring Boot properties and tell it to use the EJB3NamingStrategy, which doesn’t convert camelCase to snake_case, but keeps it as it is.

Leave a Comment