public class HibernateTopiaSqlSupport extends Object implements TopiaSqlSupport
| Modifier and Type | Class and Description |
|---|---|
static class |
HibernateTopiaSqlSupport.HibernateSqlWork |
static class |
HibernateTopiaSqlSupport.HibernateTopiaSqlQueryWork<O> |
static class |
HibernateTopiaSqlSupport.HibernateTopiaSqlWork |
| Modifier and Type | Field and Description |
|---|---|
protected TopiaHibernateSupport |
hibernateSupport |
protected org.hibernate.Session |
session |
protected Optional<Duration> |
slowQueriesThreshold
Delay after which Topia should consider a query as slow then log a warn.
|
| Constructor and Description |
|---|
HibernateTopiaSqlSupport(org.hibernate.Session session) |
HibernateTopiaSqlSupport(TopiaHibernateSupport hibernateSupport,
Optional<Duration> slowQueriesThreshold) |
| Modifier and Type | Method and Description |
|---|---|
void |
doSqlWork(TopiaSqlWork sqlWork)
Runs the given SQL work on the current context
|
void |
executeSql(String sqlScript)
Execute a given SQL code inside this transaction.
|
<O> List<O> |
findMultipleResult(SqlFunction<Connection,PreparedStatement> preparer,
SqlFunction<ResultSet,O> transformer)
Runs the given SQL query and return all his result if there is some.
|
<O> List<O> |
findMultipleResult(String sql,
SqlFunction<ResultSet,O> transformer)
Runs the given SQL query and return all his result if there is some.
|
<O> List<O> |
findMultipleResult(TopiaSqlQuery<O> query)
Runs the given SQL query and return all his result if there is some.
|
<O> O |
findSingleResult(SqlFunction<Connection,PreparedStatement> preparer,
SqlFunction<ResultSet,O> transformer)
Runs the given SQL query and return its first result if there is some.
|
<O> O |
findSingleResult(String sql,
SqlFunction<ResultSet,O> transformer)
Runs the given SQL query and return its first result if there is some.
|
<O> O |
findSingleResult(TopiaSqlQuery<O> query)
Runs the given SQL query and return its first result if there is some.
|
protected org.hibernate.Session |
getHibernateSession() |
protected SlowQueryWatcher |
monitorWork(org.hibernate.jdbc.Work query) |
void |
setSlowQueriesThreshold(Duration slowQueriesThreshold)
Tells to the context after which delay a query should be considered as slow.
|
protected TopiaHibernateSupport hibernateSupport
protected org.hibernate.Session session
public HibernateTopiaSqlSupport(TopiaHibernateSupport hibernateSupport, Optional<Duration> slowQueriesThreshold)
public HibernateTopiaSqlSupport(org.hibernate.Session session)
public void setSlowQueriesThreshold(Duration slowQueriesThreshold)
TopiaSqlSupportsetSlowQueriesThreshold in interface TopiaSqlSupportslowQueriesThreshold - the new value to setprotected SlowQueryWatcher monitorWork(org.hibernate.jdbc.Work query)
public void executeSql(String sqlScript)
TopiaSqlSupportexecuteSql in interface TopiaSqlSupportsqlScript - the sql script to executeprotected org.hibernate.Session getHibernateSession()
public void doSqlWork(TopiaSqlWork sqlWork)
TopiaSqlSupportdoSqlWork in interface TopiaSqlSupportsqlWork - the SQL work instance to executepublic <O> O findSingleResult(TopiaSqlQuery<O> query) throws TopiaException
TopiaSqlSupportfindSingleResult in interface TopiaSqlSupportO - type of resultquery - query to playnull if none found.TopiaException - for any pbpublic <O> O findSingleResult(SqlFunction<Connection,PreparedStatement> preparer, SqlFunction<ResultSet,O> transformer) throws TopiaException
TopiaSqlSupportfindSingleResult in interface TopiaSqlSupportO - type of resultpreparer - function to prepare the querytransformer - function to transform the ResultSet into the expected elementnull if none found.TopiaException - for any pbpublic <O> O findSingleResult(String sql, SqlFunction<ResultSet,O> transformer) throws TopiaException
TopiaSqlSupportfindSingleResult in interface TopiaSqlSupportO - type of resultsql - the sql querytransformer - function to transform the ResultSet into the expected elementnull if none found.TopiaException - for any pbpublic <O> List<O> findMultipleResult(TopiaSqlQuery<O> query) throws TopiaException
TopiaSqlSupportfindMultipleResult in interface TopiaSqlSupportO - type of resultquery - query to playTopiaException - for any pbpublic <O> List<O> findMultipleResult(SqlFunction<Connection,PreparedStatement> preparer, SqlFunction<ResultSet,O> transformer) throws TopiaException
TopiaSqlSupportfindMultipleResult in interface TopiaSqlSupportO - type of resultpreparer - function to prepare the querytransformer - function to transform the ResultSet into the expected elementTopiaException - for any pbpublic <O> List<O> findMultipleResult(String sql, SqlFunction<ResultSet,O> transformer) throws TopiaException
TopiaSqlSupportfindMultipleResult in interface TopiaSqlSupportO - type of resultsql - the sql querytransformer - function to transform the ResultSet into the expected elementTopiaException - for any pbCopyright © 2004–2020 Code Lutin. All rights reserved.