0

I use springboot 2.6 and postgres 15 and hibernate 5.7 I use database Generate persistence Mapping to make entity from database schema; When I run application with this config:

spring.jpa.hibernate.ddl-auto=validate

table properties name not work. for example this is my field:

@Basic
@Column(name = "isEnabled", nullable = false)
private boolean isEnabled;

When I run applicataion get this error:

Caused by: org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: missing column [is_enabled] in table [analytics]
kerbermeister
  • 2,985
  • 3
  • 11
  • 30
Mehdi Mousavi
  • 105
  • 1
  • 11
  • 1
    Spring sets its own naming convention on your columns, turning 'isEnabled' into "is_enabled". See https://stackoverflow.com/questions/36451620/hibernate-field-naming-issue-with-spring-boot-naming-strategy – Chris Feb 07 '23 at 20:32
  • Does this answer your question? [Hibernate field naming issue with Spring Boot (naming strategy)](https://stackoverflow.com/questions/36451620/hibernate-field-naming-issue-with-spring-boot-naming-strategy) – Andrey B. Panfilov Feb 08 '23 at 08:08

2 Answers2

0

Can you try to add the following annotation to your Analytics entity definition?

@Table(name = "analytics", schema = "public")
Murat Yıldız
  • 11,299
  • 6
  • 63
  • 63
0

there are 2 problems. first is field name. seccond is table name; first problem fix with this config in application.properties:

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

this fix first problem. but seccond problem not fix. you should change table name with this trick: @Table(name = ""analytics"")

Mehdi Mousavi
  • 105
  • 1
  • 11