Project flyway and jpa-Ibernate getting confused

Asked

Viewed 139 times

4

In the project we are creating, on site, to the initial JPA - Ibernate, created the tables and inserted some information, for tests.

Well the project was growing and we decided to include the flyway for versioning tables, since we have seen that this project does this.

Before we put the flyway , the application_core.properties it was like that:

spring.datasource.url=jdbc:postgresql://localhost/usuarios
spring.datasource.driver-class-name=org.postgresql.Driver
spring.datasource.username=postgres
spring.datasource.password=

spring.jpa.hibernate.ddl-auto=create
spring.data.rest.base-path=/usuarios/api
server.port=8090

spring.jpa.generate-ddl=true
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.format_sql=false
spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=false
spring.jpa.properties.org.hibernate.envers.default_schema=event_log

logging.level.root=INFO
logging.level.org.hibernate.SQL=INFO
logging.level.org.springframework=INFO

That is, when starting the server, it automatically created the table, index, Constraint in the database.

now it’s like this:

spring.datasource.url=jdbc:postgresql://localhost/usuarios
spring.datasource.driver-class-name=org.postgresql.Driver
spring.datasource.username=postgres
spring.datasource.password=

spring.jpa.hibernate.ddl-auto=none
spring.data.rest.base-path=/usuarios/api
server.port=8090

spring.jpa.generate-ddl=true
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.format_sql=false
spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=false
spring.jpa.properties.org.hibernate.envers.default_schema=event_log

logging.level.root=INFO
logging.level.org.hibernate.SQL=INFO
logging.level.org.springframework=INFO

I mean, the property spring.jpa.Hibernate.ddl-auto era create and became None.

Only that even passing the spring.jpa.Hibernate.ddl-auto for None, the JPA - Ibernate is creating tables automatically.

The project is divided into modules core, Rest, useful and flyway.

In each module has a configuration:

Module flyway:

@Configuration
@EnableAspectJAutoProxy
@EntityScan(ConfiguracaoFlyway.PACOTE)
@ComponentScan({ ConfiguracaoFlyway.PACOTE })
@EnableJpaRepositories(basePackages = ConfiguracaoFlyway.PACOTE)
@PropertySource("classpath:application_flyway.properties")
public class ConfiguracaoFlyway {
    static final String PACOTE = "br.com.ghsistemas.usuarios.flyway";
}

Module core:

@Configuration
@EnableJpaAuditing
@EnableAspectJAutoProxy
@EntityScan(ConfiguracaoCore.PACOTE)
@ComponentScan({ ConfiguracaoCore.PACOTE })
@EnableJpaRepositories(basePackages = ConfiguracaoCore.PACOTE)
@PropertySource("classpath:application_core.properties")
public class ConfiguracaoCore {
    static final String PACOTE = "br.com.ghsistemas.usuarios.core";
}

The application_flyway.properties is like this:

flyway.driver=org.postgresql.Driver
flyway.urll=jdbc:postgresql://localhost/usuarios
flyway.user=postgres
flyway.password=
flyway.schemas=public

What can it be ?

  • 1

    Have you tried fully removing the property spring.jpa.hibernate.ddl-auto of the archive?

  • I’ll test and report here

  • 1

    Try to remove this property tbm spring.jpa.generate-ddl=true

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.