From e08f2bf365e0ccd7c31a89783e5d9bebf5307385 Mon Sep 17 00:00:00 2001 From: Lukas Eder Date: Fri, 24 Jun 2022 09:08:20 +0200 Subject: [PATCH] [jOOQ/jOOQ#13718] Log warning should show jOOQ-meta type to help disambiguate objects that share the same name --- .../java/org/jooq/codegen/JavaGenerator.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/jOOQ-codegen/src/main/java/org/jooq/codegen/JavaGenerator.java b/jOOQ-codegen/src/main/java/org/jooq/codegen/JavaGenerator.java index 0bc9e474ff..7e7fe01950 100644 --- a/jOOQ-codegen/src/main/java/org/jooq/codegen/JavaGenerator.java +++ b/jOOQ-codegen/src/main/java/org/jooq/codegen/JavaGenerator.java @@ -729,9 +729,11 @@ public class JavaGenerator extends AbstractGenerator { log.info(""); } + private static final record Included(String name, Definition definition) {} + private class AvoidAmbiguousClassesFilter implements Database.Filter { - private Map included = new HashMap<>(); + private Map included = new HashMap<>(); @Override public boolean exclude(Definition definition) { @@ -745,12 +747,20 @@ public class JavaGenerator extends AbstractGenerator { // Check if we've previously encountered a Java type of the same case-insensitive, fully-qualified name. String name = getStrategy().getFullJavaClassName(definition); String nameLC = name.toLowerCase(getStrategy().getTargetLocale()); - String existing = included.put(nameLC, name); + Included existing = included.put(nameLC, new Included(name, definition)); if (existing == null) return false; - log.warn("Ambiguous type name", "The object " + definition.getQualifiedOutputName() + " generates a type " + name + " which conflicts with the existing type " + existing + " on some operating systems. Use a custom generator strategy to disambiguate the types."); + log.warn("Ambiguous type name", + "The database object " + definition.getQualifiedOutputName() + + " generates a class " + name + " (" + definition.getClass() + ")" + + " which conflicts with the previously generated class " + existing.name() + " (" + existing.definition().getClass() + ")." + + " Use a custom generator strategy to disambiguate the types. More information here:\n" + + " - https://www.jooq.org/doc/latest/manual/code-generation/codegen-generatorstrategy/\n" + + " - https://www.jooq.org/doc/latest/manual/code-generation/codegen-matcherstrategy/" + ); + return true; } }