Fixed code generation issues
This commit is contained in:
parent
8a1ca11662
commit
1597e34955
@ -275,14 +275,14 @@ public class DefaultGenerator implements Generator {
|
||||
outS.printSerial();
|
||||
outS.println();
|
||||
outS.println("\t/**");
|
||||
outS.println("\t * The singleton instance of " + schema.getName());
|
||||
outS.println("\t * The singleton instance of " + database.getOutputSchema(schema.getName()));
|
||||
outS.println("\t */");
|
||||
outS.println("\tpublic static final " + strategy.getJavaClassName(schema) + " " + strategy.getJavaIdentifierUC(schema) + " = new " + strategy.getJavaClassName(schema) + "();");
|
||||
|
||||
outS.println();
|
||||
printNoFurtherInstancesAllowedJavadoc(outS);
|
||||
outS.println("\tprivate " + strategy.getJavaClassName(schema) + "() {");
|
||||
outS.println("\t\tsuper(\"" + schema.getName() + "\");");
|
||||
outS.println("\t\tsuper(\"" + database.getOutputSchema(schema.getName()) + "\");");
|
||||
outS.println("\t}");
|
||||
|
||||
outS.printInitialisationStatementsPlaceholder();
|
||||
@ -344,7 +344,7 @@ public class DefaultGenerator implements Generator {
|
||||
|
||||
GenerationWriter out = new GenerationWriter(new File(targetSchemaDir, "Sequences.java"));
|
||||
printHeader(out, schema);
|
||||
printClassJavadoc(out, "Convenience access to all sequences in " + schema.getName());
|
||||
printClassJavadoc(out, "Convenience access to all sequences in " + database.getOutputSchema(schema.getName()));
|
||||
out.println("public final class Sequences {");
|
||||
|
||||
for (SequenceDefinition sequence : database.getSequences(schema)) {
|
||||
@ -835,7 +835,7 @@ public class DefaultGenerator implements Generator {
|
||||
|
||||
GenerationWriter out = new GenerationWriter(new File(targetSchemaDir, "Tables.java"));
|
||||
printHeader(out, schema);
|
||||
printClassJavadoc(out, "Convenience access to all tables in " + schema.getName());
|
||||
printClassJavadoc(out, "Convenience access to all tables in " + database.getOutputSchema(schema.getName()));
|
||||
out.println("public final class Tables {");
|
||||
|
||||
for (TableDefinition table : database.getTables(schema)) {
|
||||
@ -877,7 +877,7 @@ public class DefaultGenerator implements Generator {
|
||||
|
||||
GenerationWriter out = new GenerationWriter(new File(targetSchemaDir, "Keys.java"));
|
||||
printHeader(out, schema);
|
||||
printClassJavadoc(out, "A class modelling foreign key relationships between tables of the " + schema.getName() + " schema");
|
||||
printClassJavadoc(out, "A class modelling foreign key relationships between tables of the " + database.getOutputSchema(schema.getName()) + " schema");
|
||||
|
||||
out.suppressWarnings("unchecked");
|
||||
out.print("public class Keys extends ");
|
||||
@ -1140,7 +1140,7 @@ public class DefaultGenerator implements Generator {
|
||||
|
||||
if (outS != null) {
|
||||
outS.printInitialisationStatement(
|
||||
"addMapping(\"" + schema.getName() + "." + udt.getName() + "\", " +
|
||||
"addMapping(\"" + database.getOutputSchema(schema.getName()) + "." + udt.getName() + "\", " +
|
||||
strategy.getFullJavaClassName(udt, "Record") + ".class);");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
@ -1249,7 +1249,7 @@ public class DefaultGenerator implements Generator {
|
||||
|
||||
GenerationWriter out = new GenerationWriter(new File(targetSchemaDir, "UDTs.java"));
|
||||
printHeader(out, schema);
|
||||
printClassJavadoc(out, "Convenience access to all UDTs in " + schema.getName());
|
||||
printClassJavadoc(out, "Convenience access to all UDTs in " + database.getOutputSchema(schema.getName()));
|
||||
out.println("public final class UDTs {");
|
||||
|
||||
for (UDTDefinition udt : database.getUDTs(schema)) {
|
||||
@ -1422,7 +1422,7 @@ public class DefaultGenerator implements Generator {
|
||||
|
||||
GenerationWriter outR = new GenerationWriter(new File(targetSchemaDir, "Routines.java"));
|
||||
printHeader(outR, schema);
|
||||
printClassJavadoc(outR, "Convenience access to all stored procedures and functions in " + schema.getName());
|
||||
printClassJavadoc(outR, "Convenience access to all stored procedures and functions in " + database.getOutputSchema(schema.getName()));
|
||||
|
||||
outR.println("public final class Routines {");
|
||||
for (RoutineDefinition routine : database.getRoutines(schema)) {
|
||||
|
||||
@ -158,7 +158,13 @@ public class DefaultGeneratorStrategy implements GeneratorStrategy {
|
||||
|
||||
@Override
|
||||
public String getJavaIdentifier(Definition definition) {
|
||||
return GenerationUtil.convertToJavaIdentifier(definition.getName());
|
||||
|
||||
// [#1126] TODO refactor this into input/output/label name
|
||||
String n = (definition instanceof SchemaDefinition)
|
||||
? definition.getDatabase().getOutputSchema(definition.getName())
|
||||
: definition.getName();
|
||||
|
||||
return GenerationUtil.convertToJavaIdentifier(n);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -346,7 +352,12 @@ public class DefaultGeneratorStrategy implements GeneratorStrategy {
|
||||
private String getJavaClassName0(Definition definition, String suffix) {
|
||||
StringBuilder result = new StringBuilder();
|
||||
|
||||
String name = GenerationUtil.convertToJavaIdentifier(definition.getName());
|
||||
// [#1126] TODO refactor this into input/output/label name
|
||||
String n = (definition instanceof SchemaDefinition)
|
||||
? definition.getDatabase().getOutputSchema(definition.getName())
|
||||
: definition.getName();
|
||||
|
||||
String name = GenerationUtil.convertToJavaIdentifier(n);
|
||||
result.append(StringUtils.toCamelCase(name));
|
||||
|
||||
// The POJO suffix doesn't really apply to the file name
|
||||
|
||||
@ -112,7 +112,7 @@ public abstract class AbstractDatabase implements Database {
|
||||
schemata = new ArrayList<SchemaDefinition>();
|
||||
|
||||
for (String name : getInputSchemata()) {
|
||||
schemata.add(new SchemaDefinition(this, getOutputSchema(name), null));
|
||||
schemata.add(new SchemaDefinition(this, name, null));
|
||||
}
|
||||
}
|
||||
|
||||
@ -120,9 +120,9 @@ public abstract class AbstractDatabase implements Database {
|
||||
}
|
||||
|
||||
@Override
|
||||
public final SchemaDefinition getSchema(String name) {
|
||||
public final SchemaDefinition getSchema(String inputName) {
|
||||
for (SchemaDefinition schema : getSchemata()) {
|
||||
if (schema.getName().equals(getOutputSchema(name))) {
|
||||
if (schema.getName().equals(inputName)) {
|
||||
return schema;
|
||||
}
|
||||
}
|
||||
|
||||
@ -72,7 +72,9 @@ extends AbstractDefinition {
|
||||
return getName();
|
||||
}
|
||||
else {
|
||||
return getSchema().getName() + "." + getName();
|
||||
return
|
||||
getDatabase().getOutputSchema(getSchema().getName()) + "." +
|
||||
getName();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -140,7 +140,10 @@ abstract class AbstractTypedElementDefinition<T extends Definition>
|
||||
return getContainer().getName() + "." + getName();
|
||||
}
|
||||
else {
|
||||
return getSchema().getName() + "." + getContainer().getName() + "." + getName();
|
||||
return
|
||||
getDatabase().getOutputSchema(getSchema().getName()) + "." +
|
||||
getContainer().getName() + "." +
|
||||
getName();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -51,7 +51,7 @@ public class SchemaDefinition extends AbstractDefinition {
|
||||
|
||||
@Override
|
||||
public final String getQualifiedName() {
|
||||
return getName();
|
||||
return getDatabase().getOutputSchema(getName());
|
||||
}
|
||||
|
||||
public boolean isDefaultSchema() {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<configuration xmlns="http://www.jooq.org/xsd/jooq-codegen-2.0.4.xsd">
|
||||
<configuration>
|
||||
<jdbc>
|
||||
<driver>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver>
|
||||
<url>jdbc:sqlserver://localhost:1433;databaseName=test;integratedSecurity=true</url>
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<configuration xmlns="http://www.jooq.org/xsd/jooq-codegen-2.0.4.xsd">
|
||||
<configuration>
|
||||
<jdbc>
|
||||
<driver>com.sybase.jdbc3.jdbc.SybDriver</driver>
|
||||
<url>jdbc:sybase:Tds:localhost:2638</url>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user