Index: trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/store/builder/DatabaseLocalConceptStoreBuilder.java |
— | — | @@ -660,21 +660,21 @@ |
661 | 661 | } |
662 | 662 | |
663 | 663 | private int deleteAmbiguousAliases(RelationTable aliasTable, String sourceField, String sourceNameField, String targetField, String where) throws PersistenceException { |
664 | | - String sql = "CREATE TEMPORARY TABLE bad_alias ( id INT, name varbinary(255), PRIMARY KEY (id, name) )"; |
| 664 | + String sql = "CREATE TEMPORARY TABLE bad_alias ( id INT DEFAULT NULL, name varbinary(255), PRIMARY KEY (id, name) )"; |
665 | 665 | executeUpdate("deleteAmbiguousAliases:createTemp", sql); |
666 | 666 | |
667 | 667 | sql = "INSERT IGNORE INTO bad_alias " + |
668 | 668 | " SELECT " + sourceField + ", " + sourceNameField + " " + |
669 | 669 | " FROM " + aliasTable.getSQLName() + " " + |
670 | 670 | (where==null ? "" : " WHERE " + where + " ") + |
671 | | - " GROUP BY " + sourceField + ", " + sourceNameField + " " + |
| 671 | + " GROUP BY " + (idManager!=null ? sourceField : sourceNameField ) + " " + |
672 | 672 | " HAVING count(DISTINCT " + targetField + ") > 1"; |
673 | 673 | |
674 | 674 | executeUpdate("deleteAmbiguousAliases:fillTemp", sql); |
675 | 675 | |
676 | 676 | sql = "DELETE FROM A " + |
677 | 677 | " USING " + aliasTable.getSQLName() + " AS A " + |
678 | | - " JOIN bad_alias AS T ON T.id = A." + sourceField + " AND T.name = A." + sourceNameField + " " + |
| 678 | + " JOIN bad_alias AS T ON " + (idManager!=null ? " T.id = A." + sourceField : " T.name = A." + sourceNameField ) + " " + |
679 | 679 | (where==null ? "" : " WHERE " + where + " "); |
680 | 680 | |
681 | 681 | int n = executeUpdate("deleteAmbiguousAliases:delete", sql); |