Class Deduper
- java.lang.Object
-
- com.atlassian.confluence.internal.upgrade.constraint.dedup.Deduper
-
public class Deduper extends Object
Remove duplicated rows from a table before a unique constraint can be added. This is a 2-step process: 1. Query all duplicate rows 2. Use a suitableDedupeStrategy
to delete those duplicates Note: 1. Tables with composite keys are not supported. 2. This implementation doesn't scale well because it puts everything in memory and process DMLs one at a time- Since:
- 7.1.0
-
-
Constructor Summary
Constructors Constructor Description Deduper(org.hibernate.SessionFactory sessionFactory, com.atlassian.config.db.HibernateConfig hibernateConfig)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
multipleNullsNotAllowed()
Oracle and SQL Server behave differently from the rest: two rows that contain nulls for one or more key columns and the same combination of values for the other key columns violate a unique constraint.long
removeDuplicates(String table, String idColumn, List<String> uniqueColumns, DedupeStrategy dedupeStrategy)
Remove all duplicates of combination ofuniqueColumns
fromtable
.
-
-
-
Method Detail
-
removeDuplicates
public long removeDuplicates(String table, String idColumn, List<String> uniqueColumns, DedupeStrategy dedupeStrategy) throws UpgradeException
Remove all duplicates of combination ofuniqueColumns
fromtable
. Note: names of tables and columns are not to be quoted.- Returns:
- number of duplicate rows removed
- Throws:
UpgradeException
-
multipleNullsNotAllowed
public boolean multipleNullsNotAllowed()
Oracle and SQL Server behave differently from the rest: two rows that contain nulls for one or more key columns and the same combination of values for the other key columns violate a unique constraint.- Returns:
- true if current SQL vendor doesn't accepts multiple null values in multi-column unique constraints
-
-