public abstract 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 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 net.sf.hibernate.dialect.Dialect |
getDialect() |
static net.sf.hibernate.dialect.Dialect |
getDialect(ConfluenceHibernateConfig hibernateConfig) |
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(net.sf.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 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) |
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 <T> T |
withNewConnection(org.springframework.transaction.PlatformTransactionManager transactionManager,
net.sf.hibernate.SessionFactory sessionFactory,
com.google.common.base.Function<Connection,T> callback) |
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
org.springframework.dao.DataAccessException
- if the connection cannot be retrievedpublic static void flushAndClear(net.sf.hibernate.Session session) throws org.springframework.dao.DataAccessException
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(net.sf.hibernate.SessionFactory sessionFactory)
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 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
public static Set<String> filterToExistingTables(Set<String> tableNames, org.springframework.transaction.PlatformTransactionManager transactionManager, net.sf.hibernate.SessionFactory sessionFactory)
tableNames
- transactionManager
- public static boolean isTablePresent(String tableName, org.springframework.transaction.PlatformTransactionManager transactionManager, net.sf.hibernate.SessionFactory sessionFactory)
tableName
- transactionManager
- 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 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 <T> T withNewConnection(org.springframework.transaction.PlatformTransactionManager transactionManager, net.sf.hibernate.SessionFactory sessionFactory, com.google.common.base.Function<Connection,T> callback)
Copyright © 2003–2015 Atlassian. All rights reserved.