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
All Methods Static Methods Concrete Methods Deprecated Methods 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.DatabaseInformationgetDatabaseInformation(Connection connection, org.hibernate.SessionFactory sessionFactory)GetDatabaseInformationfrom Hibernate 5 to access database meta informationstatic org.springframework.jdbc.core.JdbcTemplategetJdbcTemplate(org.hibernate.Session session)Deprecated.since 7.18.0 due to Hibernate 2 removal.static StringgetPrimaryKeyColumnName(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 booleanisColumnPresent(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 booleanisTablePresent(String tableName, org.springframework.transaction.PlatformTransactionManager transactionManager, org.hibernate.SessionFactory sessionFactory)static <T> TrunWithNewConnection(org.springframework.transaction.PlatformTransactionManager transactionManager, org.hibernate.SessionFactory sessionFactory, Function<Connection,T> callback)
-
-
-
Method Detail
-
getJdbcTemplate
@Deprecated public static org.springframework.jdbc.core.JdbcTemplate getJdbcTemplate(org.hibernate.Session session)
Deprecated.since 7.18.0 due to Hibernate 2 removal. UseDataAccessUtils.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
GetDatabaseInformationfrom Hibernate 5 to access database meta information- Throws:
org.hibernate.JDBCExceptionSQLException
-
-