Return-Path: X-Original-To: apmail-cayenne-commits-archive@www.apache.org Delivered-To: apmail-cayenne-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5783D187C7 for ; Fri, 24 Jul 2015 14:38:18 +0000 (UTC) Received: (qmail 54693 invoked by uid 500); 24 Jul 2015 14:31:04 -0000 Delivered-To: apmail-cayenne-commits-archive@cayenne.apache.org Received: (qmail 54666 invoked by uid 500); 24 Jul 2015 14:31:04 -0000 Mailing-List: contact commits-help@cayenne.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cayenne.apache.org Delivered-To: mailing list commits@cayenne.apache.org Received: (qmail 54655 invoked by uid 99); 24 Jul 2015 14:31:04 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 24 Jul 2015 14:31:04 +0000 Date: Fri, 24 Jul 2015 14:31:04 +0000 (UTC) From: "Andrus Adamchik (JIRA)" To: commits@cayenne.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Created] (CAY-2021) cdbimport: detect when same FK constraint is defined twice MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 Andrus Adamchik created CAY-2021: ------------------------------------ Summary: cdbimport: detect when same FK constraint is defined twice Key: CAY-2021 URL: https://issues.apache.org/jira/browse/CAY-2021 Project: Cayenne Issue Type: Improvement Environment: MySQL 5.6.13-enterprise-commercial-advanced Cayenne 4.0.M3 custom build from rev 0ac54cb Reporter: Andrus Adamchik Assignee: Alex Kolonitsky Priority: Trivial I have a table that defines two constraints over the same exact FK/PK pair (this was by mistake, and I have cleaned it up since, but never the less, MySQL treats this as a valid definition) : CREATE TABLE `origin` ( `ID` int(11) unsigned NOT NULL AUTO_INCREMENT, `A2_TEAM_ID` int(11) unsigned DEFAULT NULL, PRIMARY KEY (`ID`), UNIQUE KEY `NAME` (`NAME`), KEY `A2_TEAM_ID` (`A2_TEAM_ID`), CONSTRAINT `origin_ibfk_1` FOREIGN KEY (`A2_TEAM_ID`) REFERENCES `a2_team` (`ID`), CONSTRAINT `FK_ORIGIN_TO_TEAM` FOREIGN KEY (`A2_TEAM_ID`) REFERENCES `a2_team` (`ID`) ) ENGINE=InnoDB AUTO_INCREMENT=175 DEFAULT CHARSET=utf8 When doing cdbimport from Maven, I got the following exception in the logs: [ERROR] Migration Error. Can't apply changes from token: Add Relationship (a2Team origin->a2_team.{ID, ID}) java.lang.IllegalArgumentException: An attempt to override relationship 'a2Team' at org.apache.cayenne.map.Entity.addRelationship(Entity.java:193) at org.apache.cayenne.merge.AddRelationshipToModel.execute(AddRelationshipToModel.java:43) at org.apache.cayenne.tools.dbimport.DbImportAction.execute(DbImportAction.java:218) at org.apache.cayenne.tools.dbimport.DbImportAction.execute(DbImportAction.java:118) at org.apache.cayenne.tools.DbImporterMojo.execute(DbImporterMojo.java:257) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208) [INFO] Migration Complete. [WARNING] Migration finished. The following problem(s) were ignored. [WARNING] Validation failure for java.lang.IllegalArgumentException: Migration Error. Can't apply changes from token: Add Relationship (a2Team origin->a2_team.{ID, ID}) So the exception was caught and the build ultimately succeeded, but the stack trace in the default Maven log made me think there was something wrong with the build. Perhaps we reduce the log level for the stack trace to DEBUG. The WARNING after it should be enough. So perhaps we don't log the stack trace in this situation -- This message was sent by Atlassian JIRA (v6.3.4#6332)