Skip to content

Commit

Permalink
[#4429] Add <javaTimeTypes/> to code generator configuration to gener…
Browse files Browse the repository at this point in the history
…ate Java 8 java.time types instead of java.sql types (incomplete implementation)
  • Loading branch information
lukaseder committed Jul 27, 2015
1 parent 227254c commit d89572c
Show file tree
Hide file tree
Showing 6 changed files with 841 additions and 3 deletions.
11 changes: 11 additions & 0 deletions jOOQ-codegen/src/main/java/org/jooq/util/AbstractGenerator.java
Expand Up @@ -70,6 +70,7 @@ abstract class AbstractGenerator implements Generator {
boolean generateGlobalSequenceReferences = true;
boolean generateGlobalTableReferences = true;
boolean generateGlobalUDTReferences = true;
boolean generateJavaTimeTypes = true;
boolean fluentSetters = false;
String fullyQualifiedTypes = "";

Expand Down Expand Up @@ -303,6 +304,16 @@ public void setFullyQualifiedTypes(String fullyQualifiedTypes) {
this.fullyQualifiedTypes = fullyQualifiedTypes;
}

@Override
public boolean generateJavaTimeTypes() {
return generateJavaTimeTypes;
}

@Override
public void setGenerateJavaTimeTypes(boolean generateJavaTimeTypes) {
this.generateJavaTimeTypes = generateJavaTimeTypes;
}

// ----

@Override
Expand Down
12 changes: 12 additions & 0 deletions jOOQ-codegen/src/main/java/org/jooq/util/GenerationTool.java
Expand Up @@ -412,6 +412,18 @@ else if (schema.getOutputSchema() == null) {
generator.setGeneratePojosEqualsAndHashCode(g.getGenerate().isPojosEqualsAndHashCode());
if (g.getGenerate().getFullyQualifiedTypes() != null)
generator.setFullyQualifiedTypes(g.getGenerate().getFullyQualifiedTypes());
if (g.getGenerate().isJavaTimeTypes() != null)
generator.setGenerateJavaTimeTypes(g.getGenerate().isJavaTimeTypes());

/* [java-8] */
if (true)
;
else
/* [/java-8] */
if (!Boolean.FALSE.equals(g.getGenerate().isJavaTimeTypes())) {
log.warn("INVALID CONFIG", "The java.time API cannot be used in the Java 6 distribution of jOOQ 3.7+");
generator.setGenerateJavaTimeTypes(false);
}

if (Boolean.TRUE.equals(g.getGenerate().isJpaAnnotations()))
log.warn("DEPRECATED", "The <jpaAnnotations/> flag is deprecated and used for backwards-compatibility only. It will be removed in the future.");
Expand Down
17 changes: 17 additions & 0 deletions jOOQ-codegen/src/main/java/org/jooq/util/Generator.java
Expand Up @@ -106,6 +106,7 @@ public interface Generator {
void setGenerateGeneratedAnnotation(boolean generateGeneratedAnnotation);

boolean useSchemaVersionProvider();

void setUseSchemaVersionProvider(boolean useSchemaVersionProvider);

/**
Expand Down Expand Up @@ -264,6 +265,22 @@ public interface Generator {
*/
void setFullyQualifiedTypes(String fullyQualifiedTypes);

/**
* A flag indicating whether Java 8's java.time types should be used by the
* source code generator, rather than JDBC's java.sql types.
* <p>
* This flag is ignored in the commercial Java 6 distribution of jOOQ 3.7+
*/
boolean generateJavaTimeTypes();

/**
* A flag indicating whether Java 8's java.time types should be used by the
* source code generator, rather than JDBC's java.sql types.
* <p>
* This flag is ignored in the commercial Java 6 distribution of jOOQ 3.7+
*/
void setGenerateJavaTimeTypes(boolean generateJavaTimeTypes);

/**
* The target directory
*/
Expand Down
2 changes: 1 addition & 1 deletion jOOQ-meta/pom.xml
Expand Up @@ -47,7 +47,7 @@
<schemaDirectory>src/main/resources/xsd</schemaDirectory>
<bindingDirectory>src/main/resources/xjb/codegen</bindingDirectory>
<schemaIncludes>
<include>jooq-codegen-3.6.0.xsd</include>
<include>jooq-codegen-3.7.0.xsd</include>
</schemaIncludes>
<generatePackage>org.jooq.util.jaxb</generatePackage>
<args>
Expand Down
4 changes: 2 additions & 2 deletions jOOQ-meta/src/main/resources/xjb/codegen/binding.xjb
Expand Up @@ -11,15 +11,15 @@
<jaxb:globalBindings>

<!-- Force all classes implements Serializable -->
<xjc:serializable uid="360" />
<xjc:serializable uid="370" />

<!-- [#2401] Trim unnecessary whitespace from configuration -->
<xjc:javaType name="java.lang.String" xmlType="xs:string" adapter="org.jooq.util.jaxb.tools.TrimAdapter"/>
</jaxb:globalBindings>


<!-- Annotate the following classes with @SuppressWarnings -->
<jaxb:bindings schemaLocation="../../xsd/jooq-codegen-3.6.0.xsd" multiple="true" node="//xs:complexType">
<jaxb:bindings schemaLocation="../../xsd/jooq-codegen-3.7.0.xsd" multiple="true" node="//xs:complexType">
<annox:annotate>
<annox:annotate annox:class="java.lang.SuppressWarnings" value="all" />
</annox:annotate>
Expand Down

0 comments on commit d89572c

Please sign in to comment.