Class DataAccessUtils

java.lang.Object
com.atlassian.confluence.upgrade.upgradetask.DataAccessUtils

public final class DataAccessUtils extends Object
Provides access to several underlying Hibernate and JDBC data access objects, which are commonly used in database-related upgrade tasks.
Since:
3.5
  • Method Summary

    Modifier and Type
    Method
    Description
    static Set<String>
    filterToExistingTables(Set<String> tableNames, org.springframework.transaction.PlatformTransactionManager transactionManager, org.hibernate.SessionFactory sessionFactory)
     
    static org.hibernate.tool.schema.extract.spi.DatabaseInformation
    getDatabaseInformation(Connection connection, org.hibernate.SessionFactory sessionFactory)
    Get DatabaseInformation from Hibernate 5 to access database meta information
    static org.springframework.jdbc.core.JdbcTemplate
    getJdbcTemplate(org.hibernate.Session session)
    Deprecated.
    since 7.18.0 due to Hibernate 2 removal.
    static String
    getPrimaryKeyColumnName(org.springframework.transaction.PlatformTransactionManager transactionManager, org.hibernate.SessionFactory sessionFactory, String tableName)
    Locates the name of the column used as the primary key on the given table.
    static boolean
    isColumnPresent(String tableName, String columnName, org.springframework.transaction.PlatformTransactionManager transactionManager, org.hibernate.SessionFactory sessionFactory, BootstrapManager bootstrapManager)
    Get whether a column is present in the database.
    static boolean
    isTablePresent(String tableName, org.springframework.transaction.PlatformTransactionManager transactionManager, org.hibernate.SessionFactory sessionFactory)
     
    static <T> T
    runWithNewConnection(org.springframework.transaction.PlatformTransactionManager transactionManager, org.hibernate.SessionFactory sessionFactory, Function<Connection,T> callback)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getJdbcTemplate

      @Deprecated public static org.springframework.jdbc.core.JdbcTemplate getJdbcTemplate(org.hibernate.Session session)
      Deprecated.
      since 7.18.0 due to Hibernate 2 removal. Use DataAccessUtils.getJdbcTemplate(org.hibernate.Session) instead.
      Returns a JDBC template for the provided Hibernate session. The JDBC template participates in the same transaction as the session.
    • filterToExistingTables

      public static Set<String> filterToExistingTables(Set<String> tableNames, org.springframework.transaction.PlatformTransactionManager transactionManager, org.hibernate.SessionFactory sessionFactory)
    • isTablePresent

      public static boolean isTablePresent(String tableName, org.springframework.transaction.PlatformTransactionManager transactionManager, org.hibernate.SessionFactory sessionFactory)
    • getPrimaryKeyColumnName

      public static String getPrimaryKeyColumnName(org.springframework.transaction.PlatformTransactionManager transactionManager, org.hibernate.SessionFactory sessionFactory, String tableName)
      Locates the name of the column used as the primary key on the given table.
      Returns:
      The name of the pri9mary key column
      Throws:
      IllegalStateException - if there is no primary key on the given table, or if the primary is constructed from more than one column
      Since:
      6.2.0
    • isColumnPresent

      public static boolean isColumnPresent(String tableName, String columnName, org.springframework.transaction.PlatformTransactionManager transactionManager, org.hibernate.SessionFactory sessionFactory, BootstrapManager bootstrapManager) throws com.atlassian.core.exception.InfrastructureException
      Get whether a column is present in the database.
      Throws:
      com.atlassian.core.exception.InfrastructureException
      Since:
      6.2.0
    • runWithNewConnection

      public static <T> T runWithNewConnection(org.springframework.transaction.PlatformTransactionManager transactionManager, org.hibernate.SessionFactory sessionFactory, Function<Connection,T> callback)
      Since:
      7.0.1
    • getDatabaseInformation

      public static org.hibernate.tool.schema.extract.spi.DatabaseInformation getDatabaseInformation(Connection connection, org.hibernate.SessionFactory sessionFactory) throws org.hibernate.JDBCException, SQLException
      Get DatabaseInformation from Hibernate 5 to access database meta information
      Throws:
      org.hibernate.JDBCException
      SQLException