java.lang.Object
com.aoapps.dao.base.AbstractModel
com.aoapps.dao.dbc.DatabaseModel
- All Implemented Interfaces:
Model
A base implementation of
DaoDatabase
.-
Field Summary
Modifier and TypeFieldDescriptionprotected final ThreadLocal
<Database> Uses aThreadLocal
to make sure an entire transaction is executed against the same underlying database. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected <V> V
executeTransaction
(DatabaseCallable<V> callable) Deprecated, for removal: This API element is subject to removal in a future version.protected void
executeTransaction
(DatabaseRunnable runnable) Deprecated, for removal: This API element is subject to removal in a future version.abstract Database
Gets the underlying database that should be used at this moment in time.<V> V
transactionCall
(DatabaseCallable<? extends V> callable) Executes an arbitrary transaction, providing automatic commit, rollback, and connection management.<V> V
transactionCall
(CallableE<? extends V, ? extends SQLException> callable) <V,
Ex extends Exception>
VtransactionCall
(Class<? extends Ex> exClass, DatabaseCallableE<? extends V, ? extends Ex> callable) Executes an arbitrary transaction, providing automatic commit, rollback, and connection management.<V,
Ex extends Throwable>
VtransactionCall
(Class<? extends Ex> exClass, CallableE<? extends V, ? extends Ex> callable) void
transactionRun
(DatabaseRunnable runnable) Executes an arbitrary transaction, providing automatic commit, rollback, and connection management.void
transactionRun
(RunnableE<? extends SQLException> runnable) <Ex extends Exception>
voidtransactionRun
(Class<? extends Ex> exClass, DatabaseRunnableE<? extends Ex> runnable) Executes an arbitrary transaction, providing automatic commit, rollback, and connection management.<Ex extends Throwable>
voidtransactionRun
(Class<? extends Ex> exClass, RunnableE<? extends Ex> runnable) Methods inherited from class com.aoapps.dao.base.AbstractModel
getComparator
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.aoapps.dao.Model
clearAllCaches, executeTransaction, getName, getReports, getTables
-
Field Details
-
transactionDatabase
Uses aThreadLocal
to make sure an entire transaction is executed against the same underlying database. This way, nothing funny will happen if master/slave databases are switched mid-transaction.
-
-
Constructor Details
-
DatabaseModel
public DatabaseModel()
-
-
Method Details
-
getDatabase
Gets the underlying database that should be used at this moment in time. It is possible that the database will change in a fail-over state. Within a single transaction, however, the database returned must be the same.- Throws:
SQLException
-
transactionCall
public <V> V transactionCall(CallableE<? extends V, ? extends SQLException> callable) throws SQLException- Throws:
SQLException
- See Also:
-
transactionCall
public <V,Ex extends Throwable> V transactionCall(Class<? extends Ex> exClass, CallableE<? extends V, ? extends Ex> callable) throws SQLException, Ex- Type Parameters:
Ex
- An arbitrary exception type that may be thrown- Throws:
SQLException
Ex
- See Also:
-
transactionCall
Executes an arbitrary transaction, providing automatic commit, rollback, and connection management.- Throws:
SQLException
- See Also:
-
executeTransaction
@Deprecated(forRemoval=true) protected <V> V executeTransaction(DatabaseCallable<V> callable) throws SQLException Deprecated, for removal: This API element is subject to removal in a future version.Executes an arbitrary transaction, providing automatic commit, rollback, and connection management.- Throws:
SQLException
-
transactionCall
public <V,Ex extends Exception> V transactionCall(Class<? extends Ex> exClass, DatabaseCallableE<? extends V, ? extends Ex> callable) throws SQLException, ExExecutes an arbitrary transaction, providing automatic commit, rollback, and connection management.- Type Parameters:
Ex
- An arbitrary exception type that may be thrown- Throws:
SQLException
Ex
- See Also:
-
transactionRun
- Throws:
SQLException
- See Also:
-
transactionRun
public <Ex extends Throwable> void transactionRun(Class<? extends Ex> exClass, RunnableE<? extends Ex> runnable) throws SQLException, Ex - Type Parameters:
Ex
- An arbitrary exception type that may be thrown- Throws:
SQLException
Ex
- See Also:
-
transactionRun
Executes an arbitrary transaction, providing automatic commit, rollback, and connection management.- Throws:
SQLException
- See Also:
-
executeTransaction
@Deprecated(forRemoval=true) protected void executeTransaction(DatabaseRunnable runnable) throws SQLException Deprecated, for removal: This API element is subject to removal in a future version.Executes an arbitrary transaction, providing automatic commit, rollback, and connection management.- Throws:
SQLException
-
transactionRun
public <Ex extends Exception> void transactionRun(Class<? extends Ex> exClass, DatabaseRunnableE<? extends Ex> runnable) throws SQLException, Ex Executes an arbitrary transaction, providing automatic commit, rollback, and connection management.- Type Parameters:
Ex
- An arbitrary exception type that may be thrown- Throws:
SQLException
Ex
- See Also:
-
transactionCall(com.aoapps.dbc.DatabaseCallable)