0
Good morning to all.
I’m trying to communicate with a Postgress database and so far so good. Inside the bank I have a table called Clientelegado. But every time the application goes up a legacy cliente_table is created.
I’ve tried using @Table(name="Clientelegacy"). I have tried without @Table and use the class name just like the table, but Hibernate insists on create this legacy cliente_table. As I will only consume the data of this table and I can not take the risk of making changes in the database, I am commenting on the line below:
@GeneratedValue(strategy = GenerationType.IDENTITY)
As I am developing a Rest Api, the return I have is from the legacy cliente_table and not from the Clientelegacy table.
This could be some problem in the application.properties ?
Configuration of application.properties
## Spring DATASOURCE (DataSourceAutoConfiguration & DataSourceProperties)
spring.datasource.url=jdbc:postgresql://localhost:5431/comunicacao
spring.datasource.username=postgres
spring.datasource.password=056409
#spring.jpa.hibernate.naming.implicit- strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyJpaImpl
#spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
spring.jpa.show-sql=true
# The SQL dialect makes Hibernate generate better SQL for the chosen database
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect
# Hibernate ddl auto (create, create-drop, validate, update)
spring.jpa.hibernate.ddl-auto = update
#spring.jpa.generate-ddl=true
#spring.jpa.hibernate.ddl-auto=validate
spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults = false
spring.flyway.baselineOnMigrate = true
#server.port=8083
Class Configuration
@Entity
@Table(name="ClienteLegado")
public class Cliente implements Serializable {
private static final long serialVersionUID = 1L;
@Id
// @GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "ClienteLegadoId")
private Long id;
Changing the naming Strategy now it keeps creating the table like this : cliente_legacy where the table name in the bank is Clientelegacy. In my view it should not create any table. Have any more idea what this problem might be ?
– Josemar Sabino
What version of Spring are you using?
– renanvm
Postgresql uses two types of identifiers, the common identifier that does not differentiate between upper and lower case and the delimited identifier (or quoted Identifier), written in quotation marks and that must follow exactly as written in its definition. Thus name, NAME and Name refer to the same identifier but "identifier", "Identifier" or "IDENTIFIER" are different. Check how you, or your application, made the setting in your database.
– anonimo