Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Still missing files #5

Closed
relio opened this issue Jan 28, 2019 · 4 comments
Closed

Still missing files #5

relio opened this issue Jan 28, 2019 · 4 comments

Comments

@relio
Copy link

relio commented Jan 28, 2019

Hi!
Sorry, after reading the good first issue I still have problem on compiling the project.
I have Postgres instead of MySql so I changed the configuration as follows:

application.yml:

spring:
    datasource:
            type: com.zaxxer.hikari.HikariDataSource
            url: jdbc:postgresql://localhost:5460/subjects_db
            username: subjects_user
            password: password
            hikari:
                data-source-properties:
                    cachePrepStmts: true
                    prepStmtCacheSize: 250
                    prepStmtCacheSqlLimit: 2048
                    useServerPrepStmts: true
    jooq:
        sql-dialect: Postgres

application:
    table-to-export: subjects_data
    ignored-table-names:
        - databasechangelog
        - databasechangeloglock
    export:
        path: ./my-project-jdl.jh
        type: jdl

pom.xml:

<properties>
   <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
   <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
   <java.version>1.8</java.version>
   <guava.version>27.0-jre</guava.version>
   <skip.jooq.generation>false</skip.jooq.generation>
   <database.url>jdbc:postgresql://localhost:5460/subjects_db</database.url>
</properties>

<dependency>
   <groupId>org.postgresql</groupId>
   <artifactId>postgresql</artifactId>
   <version>42.2.5</version>
</dependency>

<configuration>
   <jdbc>
      <driver>org.postgresql.Driver</driver>
      <url>${database.url}</url>
      <user>subjects_user</user>
      <password>password</password>
   </jdbc>
   <generator>
      <name>org.jooq.codegen.JavaGenerator</name>
      <database>
         <name>org.jooq.meta.postgres.PostgresDatabase</name>
         <includes>.*</includes>
         <excludes></excludes>
         <!--<inputSchema></inputSchema>--> <!-- This will generate all schema of db, better to only generate the one interested in -->
         <inputSchema>subjects_data</inputSchema>
      </database>
      <target>
         <packageName>org.blackdread.sqltojava.jooq</packageName>
         <directory>target/generated-sources/jooq</directory>
      </target>
   </generator>
</configuration>

I have compiled the project first with mvn compile, I have seen the souyrce code generated in the target dir, but I still got:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project sql-to-java: Compilation failure: Compilation failure:
[ERROR] ~/jhipster/sql-to-jdl-master/src/main/java/org/blackdread/sqltojava/repository/InformationSchemaRepository.java:[54,38] cannot find symbol
[ERROR] symbol:   variable REFERENCED_TABLE_NAME
[ERROR] location: variable KEY_COLUMN_USAGE of type org.blackdread.sqltojava.jooq.tables.KeyColumnUsage
[ERROR] ~/jhipster/sql-to-jdl-master/src/main/java/org/blackdread/sqltojava/repository/InformationSchemaRepository.java:[53,36] cannot find symbol
[ERROR] symbol:   variable REFERENCED_TABLE_SCHEMA
[ERROR] location: variable KEY_COLUMN_USAGE of type org.blackdread.sqltojava.jooq.tables.KeyColumnUsage
[ERROR] ~/jhipster/sql-to-jdl-master/src/main/java/org/blackdread/sqltojava/repository/InformationSchemaRepository.java:[50,29] cannot find symbol
[ERROR] symbol:   variable REFERENCED_TABLE_NAME
[ERROR] location: variable KEY_COLUMN_USAGE of type org.blackdread.sqltojava.jooq.tables.KeyColumnUsage
[ERROR] ~/jhipster/sql-to-jdl-master/src/main/java/org/blackdread/sqltojava/repository/InformationSchemaRepository.java:[51,29] cannot find symbol
[ERROR] symbol:   variable REFERENCED_COLUMN_NAME
[ERROR] location: variable KEY_COLUMN_USAGE of type org.blackdread.sqltojava.jooq.tables.KeyColumnUsage
[ERROR] ~/jhipster/sql-to-jdl-master/src/main/java/org/blackdread/sqltojava/repository/InformationSchemaRepository.java:[78,56] cannot find symbol
[ERROR] symbol:   variable TABLE_COMMENT
[ERROR] location: variable TABLES of type org.blackdread.sqltojava.jooq.tables.Tables
[ERROR] -> [Help 1]

Where is my failure?

TIA,

R

@Blackdread Blackdread pinned this issue Jan 29, 2019
@Blackdread Blackdread unpinned this issue Jan 29, 2019
@Blackdread
Copy link
Owner

Blackdread commented Jan 29, 2019

You are using postgresql but I only support mysql.

I think it is possible to support it but you need to check.
Can you try to create postgresql repositories that gives same data contract as current repositories?
Then you can use @ConditionalOnProperty of Spring to either enable postgresql or mysql and add a property in application.yml
(but in fact it might still not compile due to missing jooq classes... -> instead I could include those generated classes in codebase and set jooq as false to auto-generate)

@relio
Copy link
Author

relio commented Jan 29, 2019

Hi Yoann,
thanks for you reply, I completely miss that Postgres is not supported. So, if I'm not wrong, are you suggesting that if InformationSchemaRepository would be an Interface, it should be enough to rewrite the actual queries taylored on MySQL Information_schema to retrieve from some Postgres metadata system tables:

  • TableRelationInformation and its properties:
    private final String tableName;
    private final String columnName;
    private final String referencedTableName;
    private final String referencedColumnName;

  • ColumnInformation
    private final String name;
    private final String type;
    private final String collation;
    private final boolean isNullable;
    private final boolean isPrimary;
    private final boolean isUnique;
    private final String defaultValue;
    private final String extra;
    private final String comment;

  • TableInformation
    private final String name;
    private final String comment;

and finally the list of all table name to feed the getAllTableName method?

TIA,

R

@Blackdread
Copy link
Owner

Yes exactly, it would be necessary to have InformationSchemaRepository as an Interface, then use a configuration class that expose beans of that interface, both on Conditional but only one at once (depending on option mysql or postgres).

After there is the issue of compiling the code when jOOQ generated code is missing.
For now you can either simply delete the mysql code in your local pc, do a bridge with postgres and the rest should be alright.

@Blackdread
Copy link
Owner

Closed as not supported but can be done manually

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants