4

I would like to generate diff between the current database in oracle and entities. But the diff is not generated properly and I think that liquidate doesn't see my entities.

I have created liquibase property file with these settings:

username=username
password=password
driver=oracle.jdbc.driver.OracleDriver
url=jdbc:oracle:thin:@server
referenceUrl=hibernate:spring:path.to.package.with.entities?dialect=org.hibernate.dialect.Oracle12cDialect
<liquibase.plugin.version>3.5.5</liquibase.plugin.version>
<liquibase.hibernate.version>3.6</liquibase.hibernate.version>
...
<dependencies>
<dependency>
  <groupId>org.liquibase</groupId>
  <artifactId>liquibase-core</artifactId>
  <version>3.8.0</version>
</dependency>

...

<build>
<plugins>
    <plugin>
        <groupId>org.liquibase</groupId>
        <artifactId>liquibase-maven-plugin</artifactId>
        <version>${liquibase.plugin.version}</version>
        <dependencies>
            <dependency>
                <groupId>org.liquibase.ext</groupId>
                <artifactId>liquibase-hibernate5</artifactId>
                <version>${liquibase.hibernate.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-data-jpa</artifactId>
                <version>2.1.7.RELEASE</version>
            </dependency>
            <dependency>
                <groupId>javax.validation</groupId>
                <artifactId>validation-api</artifactId>
                <version>2.0.1.Final</version>
            </dependency>
        </dependencies>
        <configuration>
            <promptOnNonLocalDatabase>false</promptOnNonLocalDatabase>
            <propertyFile>/src/main/resources/liquibase-plugin.properties</propertyFile> 
  <changeLogFile>src/main/resources/liquibase/master.xml</changeLogFile>
            <diffChangeLogFile>src/main/resources/liquibase/updates/1-changeLog.oracle.sql</diffChangeLogFile>
            <logging>debug</logging>
        </configuration>
    </plugin>
</plugins>
</build>

application-dev.yml

spring:
  datasource:
    driver-class-name: oracle.jdbc.driver.OracleDriver
    url: jdbc:oracle:thin:@server
    username: username
    password: password
  jpa:
    properties:
      hibernate:
        default_schema: schema
    show-sql: true
  liquibase:
    enabled: true
  jpa:
    hibernate:
      naming:
        physical-strategy: package.to.class.SnakeCasePhysicalNamingStrategy

And execute this command

mvn liquibase:diff -Dspring.profiles.active=dev

but the result in the 1-changeLog.oracle.sql is

DROP TABLE COUNTRY;
DROP TABLE LANGUAGE;
DROP TABLE PROFILE;
DROP TABLE REGION;
DROP TABLE TIMEZONE;
DROP TABLE USERS;
DROP TABLE USER_ADDRESS;
DROP TABLE USER_STATUS;
DROP TABLE USER_SUBSERVICE;
DROP SEQUENCE SEQ_USERS;

So in my opinion hibernate doesn't see my entities. When I set referenceUrl to a package where there are no entities, the result is the same.

I have tried with

referenceUrl=hibernate:spring:path.to.package.with.entities?dialect=org.hibernate.dialect.Oracle12cDialect&hibernate.physical_naming_strategy=package.to.class.SnakeCasePhysicalNamingStrategy

as well but the return me

Error setting up or running Liquibase: liquibase.exception.UnexpectedLiquibaseException: liquibase.exception.DatabaseException: java.lang.ClassNotFoundExcept
ion: package.to.class.SnakeCasePhysicalNamingStrategy

and the class is in the same package as entities.

Where can be the issue why hibernate/liquibase dont see my entities? Thank you.

Jeriiii
  • 41
  • 2

0 Answers0