Stack Exchange
HibernateException: Missing column: Wrong name
In my Java code, I have a field named isNegative with a similar column existing in database. But Hibernate insists the name should be is_negative, even with forcing the name with @Column.
@Column(name="isNegative")
private boolean isNegative;

Error:

Caused by: org.hibernate.HibernateException: Missing column:
  is_negative in datasource.item

Application.properties:
#JPA
spring.data.jpa.repositories.enabled=false
spring.jpa.database=mysql
spring.jpa.database-platform=org.hibernate.dialect.MySQL5Dialect
spring.jpa.generate-ddl=true
spring.jpa.open-in-view=true
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
spring.jpa.hibernate.ddl-auto=validate
spring.jpa.hibernate.use-new-id-generator-mappings=false
spring.jpa.properties.hibernate.event.merge.entity_copy_observer=allow
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
spring.jpa.properties.hibernate.current_session_context_class=org.springframework.orm.hibernate5.SpringSessionContext


Can you show file hibernate.cfg.xml or application.properties in case you use Hibernate and Spring Framework together, or persistence.xml in case you use Hibernate as a JPA implement?

Possible duplicate of hibernate column name issues

@Arnaud Yes, totally; but the thing is the mitigation doesn't work. I set the naming strategy to physicalNamingStrategyStandard; but it doesn't work.
The workaround (writing @column(name="isnegative")) works; but it is too much to do so for all my column names.

That's due to your configuration, because you are setting  spring.jpa.hibernate.naming.physical-strategy to PhysicalNamingStrategyStandardImpl which will use underscores for the names.
If you check the Configure Hibernate Naming Strategy section of Spring Docs, you can see that:

Hibernate uses two different naming strategies to map names from the object model to the corresponding database names. The fully qualified class name of the physical and the implicit strategy implementations can be configured by setting the spring.jpa.hibernate.naming.physical-strategy and spring.jpa.hibernate.naming.implicit-strategy properties, respectively. Alternatively, if ImplicitNamingStrategy or PhysicalNamingStrategy beans are available in the application context, Hibernate will be automatically configured to use them.
By default, Spring Boot configures the physical naming strategy with
  SpringPhysicalNamingStrategy. This implementation provides the same
  table structure as Hibernate 4: all dots are replaced by underscores
  and camel casing is replaced by underscores as well. By default, all
  table names are generated in lower case, but it is possible to
  override that flag if your schema requires it.

To solve that you need to remove this property and use  the default naming strategy instead:
spring.jpa.hibernate.naming-strategy=org.hibernate.cfg.DefaultNamingStrategy


Thanks, what is the solution?

No use spring.jpa.hibernate.naming-strategy=org.hibernate.cfg.DefaultNamingStrategy instead check my Edit.

You would need spring.jpa.hibernate.naming.physical-strategy and spring.jpa.hibernate.naming.implicit-strategy 
Adding following
spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyJpaImpl
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl

to application.properties could help. This solution would work from hibernate 5.
Hope it helps.

Please find below my analysis:
If you don't want your naming strategy to add an underscore to the column name or class name, then the strategy that you need to use would look like: spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl. The things that you provide in annotations @Table and @Column’s name attribute would remain as it is. E.g. firstName attribute in entity will get a column name as firstName i.e. No change.
If you don't want to provide annotations and want to manually handle the table name and column names, you should extend the class org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl and override the required methods. If you still use annotations for some of the cases here, remember the overridden methods will apply on the names written in those annotations. spring.jpa.hibernate.naming.physical-strategy=example.CustomStrategy
