MetadataExporter should provide option to override output schema #1473

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

Projects

None yet

2 participants

@holgerstolzenberg

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
Member

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

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

@holgerstolzenberg

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 closed this in #1488 Aug 28, 2015
@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