From 05c309ddfce06244c3d45c8f0f06583785b25099 Mon Sep 17 00:00:00 2001 From: lukaseder Date: Tue, 7 Jun 2016 21:50:42 +0300 Subject: [PATCH] [#5335] Log a warning in the code generator if a table is reported to have two identity columns --- .../AbstractElementContainerDefinition.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/jOOQ-meta/src/main/java/org/jooq/util/AbstractElementContainerDefinition.java b/jOOQ-meta/src/main/java/org/jooq/util/AbstractElementContainerDefinition.java index b7aad39fce..689f4ac10b 100644 --- a/jOOQ-meta/src/main/java/org/jooq/util/AbstractElementContainerDefinition.java +++ b/jOOQ-meta/src/main/java/org/jooq/util/AbstractElementContainerDefinition.java @@ -92,6 +92,24 @@ extends AbstractDefinition { Database db = getDatabase(); List e = getElements0(); + // [#5335] Warn if a table definition contains several identity columns + if (this instanceof TableDefinition) { + boolean hasIdentity = false; + + for (E c : e) { + boolean isIdentity = ((ColumnDefinition) c).isIdentity(); + + if (isIdentity) { + if (hasIdentity) { + log.warn("Multiple identities", "Table " + getOutputName() + " has multiple identity columns. Only the first one is considered."); + break; + } + + hasIdentity = true; + } + } + } + // [#2603] Filter exclude / include also for table columns if (this instanceof TableDefinition && db.getIncludeExcludeColumns()) { elements = db.filterExcludeInclude(e);