I'm having some problems with my PostgreSQL database columns on some tables.
If I declare a column of String
with a name like a_column_name
Hibernate accepts the column of the table with the name a_column_name
.
But my problem comes when I declare the column type to Integer
or BigDecimal
. At start, Hibernate creates a new column of type int4
or numeric(19, 2)
with a name like acolumnname with NULL's.
Hibernate: alter table t_myTable add column acolumnname int4
or
Hibernate: alter table t_myTable add column acolumnname numeric(19, 2)
I've tried to set the name-strategy on the config file of Spring boot:
jpa:
show-sql: true
hibernate:
ddl-auto: update
properties:
hibernate.cache.use_second_level_cache: false
hibernate.cache.use_query_cache: false
hibernate.generate_statistics: true
naming.physical-strategy: PhysicalNamingStrategyStandardImpl
But with no result...
So my question is why Hibernate accepts the column name when it's of String type but doesn't like it when it's Integer or BigDecimal.
Regards.
---- Update 1 ----
After search the Entity to post here the code as Veselin Davidov asked, I've noticed that some columns are accepted while others not.
The entities are created from a company framework that parses a JSON with the DB structure (tables, fields, type of fields...) and generates the JAVA entity class. So after see the answer from SAM I've changed the code of the Entity template to add a @Column(name = "your_column_name")
. Now, when Hibernate starts, it doesn't add the columns with the wrong names and uses the DB columns.