Class DbConnectionManagerImpl
- All Implemented Interfaces:
DbConnectionManager
-
Constructor Summary
ConstructorsConstructorDescriptionDbConnectionManagerImpl
(DatabaseConfigurationManager databaseConfigurationManager, org.ofbiz.core.entity.DelegatorInterface delegatorInterface, OfBizConnectionFactory ofBizConnectionFactory) -
Method Summary
Modifier and TypeMethodDescriptionvoid
execute
(SqlCallback callback) Executes SQL statements as defined in the callback function.<T> T
executeQuery
(QueryCallback<T> callback) Executes SQL statements as defined in the callback function and returns the results.com.querydsl.sql.SQLTemplates
This will return a DB dialect as appropriate for usage with Querydsl.
-
Constructor Details
-
DbConnectionManagerImpl
public DbConnectionManagerImpl(DatabaseConfigurationManager databaseConfigurationManager, org.ofbiz.core.entity.DelegatorInterface delegatorInterface, OfBizConnectionFactory ofBizConnectionFactory)
-
-
Method Details
-
executeQuery
Description copied from interface:DbConnectionManager
Executes SQL statements as defined in the callback function and returns the results.This method is mostly useful for running SELECT statements and returning the given results in some form.
Even if OfBiz is currently running in a ThreadLocal transaction, this will retrieve a fresh connection from the pool. Do not close the given connection - this manager will return it to the pool after the method is complete. If the Callback function throws a RuntimeException and the connection is not in auto-commit mode, then this method will perform a rollback on the connection.
The connection will have the default auto-commit value as defined by the JIRA connection pool. As at JIRA 6.4 this means autocommit == true. See
org.apache.commons.dbcp.PoolableConnectionFactory#activateObject(Object)
for details.- Specified by:
executeQuery
in interfaceDbConnectionManager
- Type Parameters:
T
- type of results- Parameters:
callback
- the callback function that runs the query- Returns:
- results of the callback function
- See Also:
-
getDialect
@Nonnull public com.querydsl.sql.SQLTemplates getDialect()Description copied from interface:DbConnectionManager
This will return a DB dialect as appropriate for usage with Querydsl.- Specified by:
getDialect
in interfaceDbConnectionManager
- Returns:
- a DB dialect as appropriate for usage with Querydsl.
-
execute
Description copied from interface:DbConnectionManager
Executes SQL statements as defined in the callback function.This method does not return results and is mostly useful for running INSERT, UPDATE, and DELETE operations.
Example Usage:
dbConnectionManager.execute(new SqlCallback() { public void run(final DbConnection dbConnection) { dbConnection.update(QIssueLink.ISSUE_LINK) .set(QIssueLink.ISSUE_LINK.linktype, issueLinkType.getId()) .where(QIssueLink.ISSUE_LINK.id.eq(issueLink.getId())) .execute(); } });
Even if OfBiz is currently running in a ThreadLocal transaction, this will retrieve a fresh connection from the pool. Do not close the given connection - this manager will return it to the pool after the method is complete. If the Callback function throws a RuntimeException and the connection is not in auto-commit mode, then this method will perform a rollback on the connection.
The connection will have the default auto-commit value as defined by the JIRA connection pool. As at JIRA 6.4 this means autocommit == true. See
org.apache.commons.dbcp.PoolableConnectionFactory#activateObject(Object)
for details.- Specified by:
execute
in interfaceDbConnectionManager
- Parameters:
callback
- the callback function that runs the query- See Also:
-