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
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(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–2016 Atlassian. All rights reserved.