Class HibernateCheckConstraint

java.lang.Object
com.atlassian.confluence.upgrade.impl.HibernateCheckConstraint

public class HibernateCheckConstraint extends Object
It creates a predicate for checking whether constraint of specified name exists or not.
Since:
5.10
  • Constructor Details

    • HibernateCheckConstraint

      public HibernateCheckConstraint()
  • Method Details

    • createConstraintPredicate

      @Deprecated public static Predicate<String> createConstraintPredicate(com.atlassian.config.db.HibernateConfig hibernateConfig, org.hibernate.SessionFactory sessionFactory)
      Deprecated.
      since 7.13.17
    • createConstraintPredicate

      public static Predicate<String> createConstraintPredicate(HibernateDatabaseCapabilities databaseCapabilities, org.hibernate.SessionFactory sessionFactory)
      Since:
      7.13.17
    • getConstraintsForTable

      public static Map<String,List<String>> getConstraintsForTable(com.atlassian.config.db.HibernateConfig hibernateConfig, org.hibernate.SessionFactory sessionFactory, @NonNull String tableName)
      Return a map of unique contraints and it's columns for the given table.
      Parameters:
      tableName - a table name.
      Returns:
      map of (constraint_name -> list(columns_name)). Empty if table doesn't exist, or no unique constraints.
    • constraintsExists

      @Deprecated public static boolean constraintsExists(com.atlassian.config.db.HibernateConfig hibernateConfig, org.hibernate.SessionFactory sessionFactory, Map<String,com.atlassian.fugue.Pair<String,List<String>>> expectedConstraints)
      Take an expected map of [tablename, pair[constraint name, list[column name for constraint]]], and work out if the given constraints for the given table exists in the database.
      Parameters:
      hibernateConfig - hibernate config
      sessionFactory - sessionFactory
      expectedConstraints - a map of tablename -> pair[constraint name, list[column name for constraint]], of the expected constraints.
      Returns:
      true if all of the constraints exist, false otherwise. If any of the table doesn't exist, return false.
    • checkConstraintsExists

      public static boolean checkConstraintsExists(com.atlassian.config.db.HibernateConfig hibernateConfig, org.hibernate.SessionFactory sessionFactory, Map<String,io.atlassian.fugue.Pair<String,List<String>>> expectedConstraints)
      Take an expected map of [tablename, pair[constraint name, list[column name for constraint]]], and work out if the given constraints for the given table exists in the database.
      Parameters:
      hibernateConfig - hibernate config
      sessionFactory - sessionFactory
      expectedConstraints - a map of tablename -> pair[constraint name, list[column name for constraint]], of the expected constraints.
      Returns:
      true if all of the constraints exist, false otherwise. If any of the table doesn't exist, return false.
      Since:
      7.0.1