public final class DataAccessUtils extends Object
Modifier and Type | Method and Description |
---|---|
static Set<String> |
filterToExistingTables(Set<String> tableNames,
org.springframework.transaction.PlatformTransactionManager transactionManager,
net.sf.hibernate.SessionFactory sessionFactory)
Within a new transaction (for DB metadata retrieval), return the supplied Set of tables names filtered such that all the tables
that don't exist are removed.
|
static Set<String> |
filterToExistingTables(Set<String> tableNames,
org.springframework.transaction.PlatformTransactionManager transactionManager,
org.hibernate.SessionFactory sessionFactory) |
static void |
flush(net.sf.hibernate.Session session)
Flushes the session.
|
static void |
flushAndClear(net.sf.hibernate.Session session)
Flushes and clears the session.
|
static Connection |
getConnection(net.sf.hibernate.Session session)
Returns the JDBC connection for the session.
|
static Connection |
getConnection(org.hibernate.Session session) |
static net.sf.hibernate.dialect.Dialect |
getDialect() |
static net.sf.hibernate.dialect.Dialect |
getDialect(ConfluenceHibernateConfig hibernateConfig) |
static org.hibernate.dialect.Dialect |
getDialectV5()
Deprecated.
since 6.4.1. Use
DataAccessUtils.getDialect() instead. |
static org.hibernate.dialect.Dialect |
getDialectV5(ConfluenceHibernateConfig hibernateConfig)
Deprecated.
since 6.4.1. Use
DataAccessUtils.getDialect(ConfluenceHibernateConfig) instead. |
static org.springframework.jdbc.core.JdbcTemplate |
getJdbcTemplate(net.sf.hibernate.Session session)
Returns a JDBC template for the provided Hibernate session.
|
static org.springframework.jdbc.core.JdbcTemplate |
getJdbcTemplate(org.hibernate.Session session)
Returns a JDBC template for the provided Hibernate session.
|
static org.springframework.jdbc.core.JdbcTemplate |
getJdbcTemplate(net.sf.hibernate.SessionFactory sessionFactory)
Returns a JDBC template for the active Hibernate session.
|
static org.springframework.jdbc.core.JdbcTemplate |
getJdbcTemplate(org.hibernate.SessionFactory sessionFactory)
Returns a JDBC template for the active Hibernate session.
|
static String |
getPrimaryKeyColumnName(org.springframework.transaction.PlatformTransactionManager transactionManager,
net.sf.hibernate.SessionFactory sessionFactory,
String tableName)
Locates the name of the column used as the primary key on the given table.
|
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 org.hibernate.Session |
getSession(org.hibernate.SessionFactory sessionFactory)
Returns the current session or creates one if one does not exist.
|
static net.sf.hibernate.Session |
getSession(net.sf.hibernate.SessionFactory sessionFactory)
Returns the current session or creates one if one does not exist.
|
static boolean |
isColumnPresent(String tableName,
String columnName,
org.springframework.transaction.PlatformTransactionManager transactionManager,
net.sf.hibernate.SessionFactory sessionFactory,
BootstrapManager bootstrapManager)
Get whether a column is present in the database.
|
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,
net.sf.hibernate.SessionFactory sessionFactory)
Within a new transaction (for the database metadata lookup) check if the named table exists 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,
net.sf.hibernate.SessionFactory sessionFactory,
Function<Connection,T> callback) |
static <T> T |
runWithNewConnection(org.springframework.transaction.PlatformTransactionManager transactionManager,
org.hibernate.SessionFactory sessionFactory,
Function<Connection,T> callback) |
static <T> T |
withNewConnection(org.springframework.transaction.PlatformTransactionManager transactionManager,
net.sf.hibernate.SessionFactory sessionFactory,
com.google.common.base.Function<Connection,T> callback)
Deprecated.
|
static <T> T |
withNewConnection(org.springframework.transaction.PlatformTransactionManager transactionManager,
org.hibernate.SessionFactory sessionFactory,
com.google.common.base.Function<Connection,T> callback)
Deprecated.
|
public static org.hibernate.Session getSession(org.hibernate.SessionFactory sessionFactory)
SessionFactoryUtils.getSession(net.sf.hibernate.SessionFactory, boolean)
public static net.sf.hibernate.Session getSession(net.sf.hibernate.SessionFactory sessionFactory)
SessionFactoryUtils.getSession(net.sf.hibernate.SessionFactory, boolean)
public static void flush(net.sf.hibernate.Session session) throws org.springframework.dao.DataAccessException
This does not commit anything by itself, but relies on the surrounding transaction to commit the changes.
org.springframework.dao.DataAccessException
- if the connection cannot be retrievedpublic static void flushAndClear(net.sf.hibernate.Session session) throws org.springframework.dao.DataAccessException
This does not commit anything by itself, but relies on the surrounding transaction to commit or roll back the changes.
Use this method if you are processing a large number of Hibernate objects and want to make sure that ones which are already processed are not kept in memory.
org.springframework.dao.DataAccessException
- if the connection cannot be retrievedpublic static org.springframework.jdbc.core.JdbcTemplate getJdbcTemplate(net.sf.hibernate.Session session)
public static org.springframework.jdbc.core.JdbcTemplate getJdbcTemplate(org.hibernate.Session session)
public static org.springframework.jdbc.core.JdbcTemplate getJdbcTemplate(net.sf.hibernate.SessionFactory sessionFactory)
public static org.springframework.jdbc.core.JdbcTemplate getJdbcTemplate(org.hibernate.SessionFactory sessionFactory)
getJdbcTemplate(Session)
public static Connection getConnection(net.sf.hibernate.Session session) throws org.springframework.dao.DataAccessException
org.springframework.dao.DataAccessException
- if the connection cannot be retrievedpublic static Connection getConnection(org.hibernate.Session session)
public static net.sf.hibernate.dialect.Dialect getDialect() throws org.springframework.dao.DataAccessException
org.springframework.dao.DataAccessException
public static net.sf.hibernate.dialect.Dialect getDialect(ConfluenceHibernateConfig hibernateConfig) throws org.springframework.dao.DataAccessException
org.springframework.dao.DataAccessException
@Deprecated public static org.hibernate.dialect.Dialect getDialectV5() throws org.springframework.dao.DataAccessException
DataAccessUtils.getDialect()
instead.org.springframework.dao.DataAccessException
@Deprecated public static org.hibernate.dialect.Dialect getDialectV5(ConfluenceHibernateConfig hibernateConfig) throws org.springframework.dao.DataAccessException
DataAccessUtils.getDialect(ConfluenceHibernateConfig)
instead.hibernateConfig
- org.springframework.dao.DataAccessException
public static Set<String> filterToExistingTables(Set<String> tableNames, org.springframework.transaction.PlatformTransactionManager transactionManager, net.sf.hibernate.SessionFactory sessionFactory)
tableNames
- transactionManager
- public static Set<String> filterToExistingTables(Set<String> tableNames, org.springframework.transaction.PlatformTransactionManager transactionManager, org.hibernate.SessionFactory sessionFactory)
public static boolean isTablePresent(String tableName, org.springframework.transaction.PlatformTransactionManager transactionManager, net.sf.hibernate.SessionFactory sessionFactory)
tableName
- transactionManager
- sessionFactory
- public static boolean isTablePresent(String tableName, org.springframework.transaction.PlatformTransactionManager transactionManager, org.hibernate.SessionFactory sessionFactory)
public static String getPrimaryKeyColumnName(org.springframework.transaction.PlatformTransactionManager transactionManager, net.sf.hibernate.SessionFactory sessionFactory, String tableName)
IllegalStateException
- if there is no primary key on the given table, or if the primary is
constructed from more than one columnpublic static String getPrimaryKeyColumnName(org.springframework.transaction.PlatformTransactionManager transactionManager, org.hibernate.SessionFactory sessionFactory, String tableName)
IllegalStateException
- if there is no primary key on the given table, or if the primary is
constructed from more than one columnpublic static boolean isColumnPresent(String tableName, String columnName, org.springframework.transaction.PlatformTransactionManager transactionManager, net.sf.hibernate.SessionFactory sessionFactory, BootstrapManager bootstrapManager) throws com.atlassian.core.exception.InfrastructureException
com.atlassian.core.exception.InfrastructureException
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
com.atlassian.core.exception.InfrastructureException
@Deprecated public static <T> T withNewConnection(org.springframework.transaction.PlatformTransactionManager transactionManager, net.sf.hibernate.SessionFactory sessionFactory, com.google.common.base.Function<Connection,T> callback)
runWithNewConnection(PlatformTransactionManager, SessionFactory, Function)
public static <T> T runWithNewConnection(org.springframework.transaction.PlatformTransactionManager transactionManager, net.sf.hibernate.SessionFactory sessionFactory, Function<Connection,T> callback)
@Deprecated public static <T> T withNewConnection(org.springframework.transaction.PlatformTransactionManager transactionManager, org.hibernate.SessionFactory sessionFactory, com.google.common.base.Function<Connection,T> callback)
runWithNewConnection(PlatformTransactionManager, org.hibernate.SessionFactory, Function)
public static <T> T runWithNewConnection(org.springframework.transaction.PlatformTransactionManager transactionManager, org.hibernate.SessionFactory sessionFactory, Function<Connection,T> callback)
Copyright © 2003–2019 Atlassian. All rights reserved.