@ParametersAreNonnullByDefault @ReturnValuesAreNonnullByDefault public abstract class DataAccessUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static org.hibernate.query.NativeQuery |
createSqlQuery(org.hibernate.Session session,
String sql)
A convenience wrapper around
QueryProducer.createNativeQuery(String) which conditionally sets the query
flush mode depending on the current transaction state. |
static net.sf.hibernate.Session |
downgrade(org.hibernate.Session session)
Get the hibernate Session object with the v5 interface and hibernate implementation.
|
static net.sf.hibernate.SessionFactory |
downgrade(org.hibernate.SessionFactory sessionFactory)
Get a reference to the v5 SessionFactory interface.
|
static Set<String> |
filterToExistingTables(Set<String> tableNames,
org.springframework.transaction.PlatformTransactionManager transactionManager,
org.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(org.hibernate.Session session)
Flushes the session.
|
static Connection |
getConnection(org.hibernate.Session session)
Returns the JDBC connection for the session.
|
static org.hibernate.dialect.Dialect |
getDialect() |
static org.hibernate.dialect.Dialect |
getDialect(ConfluenceHibernateConfig hibernateConfig) |
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(org.hibernate.SessionFactory sessionFactory)
Returns a JDBC template for the active Hibernate session.
|
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 boolean |
isColumnPresent(String tableName,
String columnName,
org.springframework.transaction.PlatformTransactionManager transactionManager,
org.hibernate.SessionFactory sessionFactory,
BootstrapManager bootstrapManager) |
static boolean |
isTablePresent(String tableName,
org.springframework.transaction.PlatformTransactionManager transactionManager,
org.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,
org.hibernate.SessionFactory sessionFactory,
Function<Connection,T> callback) |
public static org.hibernate.Session getSession(org.hibernate.SessionFactory sessionFactory)
SessionFactoryUtils.getSession(net.sf.hibernate.SessionFactory, boolean)public static void flush(org.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 org.springframework.jdbc.core.JdbcTemplate getJdbcTemplate(org.hibernate.Session session)
public static org.springframework.jdbc.core.JdbcTemplate getJdbcTemplate(org.hibernate.SessionFactory sessionFactory)
public static Connection getConnection(org.hibernate.Session session) throws org.springframework.dao.DataAccessException
org.springframework.dao.DataAccessException - if the connection cannot be retrievedpublic static org.hibernate.dialect.Dialect getDialect()
throws org.springframework.dao.DataAccessException
org.springframework.dao.DataAccessExceptionpublic static org.hibernate.dialect.Dialect getDialect(ConfluenceHibernateConfig hibernateConfig) throws org.springframework.dao.DataAccessException
org.springframework.dao.DataAccessExceptionpublic 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, org.hibernate.SessionFactory sessionFactory)
public 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, org.hibernate.SessionFactory sessionFactory, BootstrapManager bootstrapManager) throws InfrastructureException
InfrastructureExceptionpublic static <T> T withNewConnection(org.springframework.transaction.PlatformTransactionManager transactionManager,
org.hibernate.SessionFactory sessionFactory,
Function<Connection,T> callback)
@Nullable public static net.sf.hibernate.SessionFactory downgrade(@Nullable org.hibernate.SessionFactory sessionFactory)
@Nullable public static net.sf.hibernate.Session downgrade(@Nullable org.hibernate.Session session)
public static org.hibernate.query.NativeQuery createSqlQuery(org.hibernate.Session session,
String sql)
QueryProducer.createNativeQuery(String) which conditionally sets the query
flush mode depending on the current transaction state.Copyright © 2003–2017 Atlassian. All rights reserved.