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

MetadataExporter should provide option to override output schema #1473

Closed
holgerstolzenberg opened this issue Aug 12, 2015 · 3 comments
Closed

MetadataExporter should provide option to override output schema #1473

holgerstolzenberg opened this issue Aug 12, 2015 · 3 comments
Milestone

Comments

@holgerstolzenberg
Copy link

@holgerstolzenberg holgerstolzenberg commented Aug 12, 2015

We are using Oracle in this case. We create our Q* classes via Gradle + AntMetadataExplorer without JPA model. When running the code generator, the schema rendered into the Q* classes in the end is the username.

In our use case that is a bit problematic. Let´s assume we have a semantical schema APPDATA. The codegen runs against a local dev vm, where we have multiple schemas, e.g. APPDATA_STAGE and APPDATA_INTEGRATION_TEST.

For sure I can take one of these and remap it at runtime with Configuration.registerSchemaOverride(…), but then the mapping would be:

APPDATA_STAGE => APPDATA[_ANY_ENV_SPECIFIC_FLAG]

It would be nice to have a schema override setting within MetadataExporter so that I can create the Q* classes with a semantically correct schema name, so that at runtime may mapping would look like:

APPDATA => APPDATA[_ANY_ENV_SPECIFIC_FLAG]

As a little motivation :-) jOOQ code generator provides this feature.

@timowest
Copy link
Member

@timowest timowest commented Aug 18, 2015

Thanks for the issue! That functionality is already there. Somehow I just missed to document it properly.

@timowest timowest added the progress label Aug 18, 2015
@holgerstolzenberg
Copy link
Author

@holgerstolzenberg holgerstolzenberg commented Aug 19, 2015

Oh nice. In the meantime, will it help to dig into AntMetadataExplorer sources. How is the config property called?

@holgerstolzenberg
Copy link
Author

@holgerstolzenberg holgerstolzenberg commented Aug 19, 2015

Having a look at your commit 96c063a, it seems that this rename functionality is only related to the maven plugin, am I right?

We are creating the Q* classes the following way:

def url = property('flyway.url');
def pass = property('flyway.password')
def driver = 'oracle.jdbc.OracleDriver'
def targetPath = projectDir.absolutePath + File.separator + 'src/generated/java'

task generateQuerydsl() {
  doFirst {
    logging.captureStandardOutput LogLevel.INFO
    println "[Querydsl]: $url"
  }

  doLast {
    ant {
      taskdef(name: 'generateQuerydsl',
          classname: 'com.querydsl.sql.codegen.ant.AntMetaDataExporter',
          classpath: configurations.compile.asPath)

      generateQuerydsl(jdbcDriver: driver,
          jdbcUrl: url,
          jdbcUser: 'the_user', jdbcPassword: pass,
          packageName: 'com.any.package',
          targetFolder: targetPath,
          schemaPattern: 'THE_SCHEMA',
          exportAll: true
      )
    }
  }
}

Digging into AntMetadataExplorer (4.0.3), it seems there is no way to register these rename mappings.

@timowest timowest added this to the 4.0.4 milestone Aug 28, 2015
@timowest timowest removed the progress label Aug 28, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.