- All Superinterfaces:
AutoCloseable,Transaction
- All Known Implementing Classes:
ExternalJdbcTransaction,JtaTransaction,ScopedTransaction,SpiTransactionProxy
Provides support for batching and TransactionContext.
-
Field Summary
Fields inherited from interface io.ebean.Transaction
READ_COMMITTED, READ_UNCOMMITTED, REPEATABLE_READ, SERIALIZABLE -
Method Summary
Modifier and TypeMethodDescriptionvoidaddBeanChange(BeanChange beanChange) Add a bean change to the change log.Return the BatchControl used to batch up persist requests.booleancheckBatchEscalationOnCascade(PersistRequestBean<?> request) Return true if batch mode got escalated for this request (and associated cascades).voidPotentially escalate batch mode on saving or deleting a collection.voidSet the transaction to be inactive via external transaction manager.default intdepth()Return the current depth.default voiddepth(int diff) Modify the current 'depth' of the transaction.default voidDecrement the depth BUT only if depth is greater than 0.default voidReset the depth back to 0 - done at the end of top level insert and update.event()Get the object that holds the event details.voidIf batch mode was turned on for the request then flush the batch.voidFlush batch if we escalated batch mode on saving or deleting a collection.voidIf batch was on then effectively clear the batch such that we can handle exceptions and continue.Return the getGeneratedKeys setting for this transaction.intReturn the batchSize specifically set for this transaction or 0.id()Returns a String used to identify the transaction.Return the underlying Connection for internal use.booleanReturn true if dirty beans are automatically persisted.booleanReturn true if this request should be batched.booleanReturn true if this transaction was created explicitly viaEbean.beginTransaction().booleanisLogSql()Return true if generated SQL and Bind values should be logged to the transaction log.booleanReturn true if summary level events should be logged to the transaction log.booleanReturn true when nested transactions should create Savepoints.booleanWhether persistCascade is on for save and delete.booleanisRegisteredBean(Object bean) Return true if this is a bean that has already been persisted in the current recursive save request.booleanisRegisteredDeleteBean(Class<?> type, Object id) Return true if this is a bean that has already been saved/deleted.booleanisSaveAssocManyIntersection(String intersectionTable, String beanName) Return true if the manyToMany intersection should be persisted for this particular relationship direction.booleanReturn true if explicitly set to skip cache (ignores skipOnWrite).Return true if this transaction has updateAllLoadedProperties set.label()Return the user defined label for the transaction.voidLog a message to the SQL logger.voidlogSummary(String msg, Object... args) Log a summary message to the SUMMARY logger.voidLog a transaction message to the transaction logger.voidMark the transaction explicitly as not being query only.Return the persistence context associated with this transaction.voidFire post commit events and listeners.voidpostRollback(Throwable cause) Fire post rollback events and listeners.voidFire pre commit processing/listeners.voidCheck if the event should be added to a profiling transaction.Return the profile location for this transaction.longReturn the offset time from the start of the transaction.Return the stream that profiling events are written to.voidRegister a "Deferred Relationship" that requires an additional update later.voidregisterDeleteBean(Class<?> type, Object id) Add a deleting bean to the registered list.voidsendChangeLog(ChangeSet changeSet) Send the change set to be prepared and then logged.default voidSet autocommit to false for a findIterate query.voidsetBatchControl(BatchControl control) Set the BatchControl used to batch up persist requests.voidSet the persistence context to this transaction.voidsetProfileLocation(ProfileLocation profileLocation) Set the profile location for this transaction.voidsetProfileStream(ProfileStream profileStream) Set the profileStream to catch and time all the events for this transaction.voidsetTenantId(Object tenantId) Set the current Tenant Id.Return the start timestamp for the transaction (JVM side).tenantId()Return the current Tenant Id.jakarta.persistence.PersistenceExceptiontranslate(String message, SQLException cause) Translate the SQLException.voidUnregister the persisted beans.Methods inherited from interface io.ebean.Transaction
addModification, close, commit, commitAndContinue, connection, end, flush, getUserObject, isActive, isBatchMode, isBatchOnCascade, isFlushOnQuery, isReadOnly, isRollbackOnly, isSkipCache, putUserObject, register, rollback, rollback, rollbackAndContinue, setAutoPersistUpdates, setBatchMode, setBatchOnCascade, setBatchSize, setFlushOnMixed, setFlushOnQuery, setGetGeneratedKeys, setLabel, setNestedUseSavepoint, setPersistCascade, setReadOnly, setRollbackOnly, setSkipCache, setUpdateAllLoadedProperties
-
Method Details
-
label
String label()Return the user defined label for the transaction. -
isLogSql
boolean isLogSql()Return true if generated SQL and Bind values should be logged to the transaction log. -
isLogSummary
boolean isLogSummary()Return true if summary level events should be logged to the transaction log. -
logSql
Log a message to the SQL logger. -
logSummary
Log a summary message to the SUMMARY logger. -
logTxn
Log a transaction message to the transaction logger. -
registerDeferred
Register a "Deferred Relationship" that requires an additional update later. -
registerDeleteBean
Add a deleting bean to the registered list.This is to handle bi-directional relationships where both sides Cascade.
-
isRegisteredDeleteBean
Return true if this is a bean that has already been saved/deleted. -
unregisterBeans
void unregisterBeans()Unregister the persisted beans. Expected after persisting top level beans and hence including all beans that were cascade persisted. -
isRegisteredBean
Return true if this is a bean that has already been persisted in the current recursive save request. The goal is to stop recursively saving the bean when cascade persist is on both sides of a relationship).This will register the bean if it is not already.
-
id
String id()Returns a String used to identify the transaction. This id is used for Transaction logging. -
startTime
Instant startTime()Return the start timestamp for the transaction (JVM side). -
isUpdateAllLoadedProperties
Boolean isUpdateAllLoadedProperties()Return true if this transaction has updateAllLoadedProperties set. If null is returned the server default is used (set on DatabaseConfig). -
getBatchSize
int getBatchSize()Return the batchSize specifically set for this transaction or 0.Returning 0 implies to use the system wide default batch size.
- Specified by:
getBatchSizein interfaceTransaction
-
getBatchGetGeneratedKeys
Boolean getBatchGetGeneratedKeys()Return the getGeneratedKeys setting for this transaction. -
depth
default void depth(int diff) Modify the current 'depth' of the transaction.As we cascade save or delete we traverse the object graph tree. Going up to Assoc Ones the depth decreases and going down to Assoc Manys the depth increases.
The depth is used for ordering batching statements. The lowest depth get executed first during save.
-
depthDecrement
default void depthDecrement()Decrement the depth BUT only if depth is greater than 0. Return the amount that depth should be incremented by (0 or 1). -
depthReset
default void depthReset()Reset the depth back to 0 - done at the end of top level insert and update. -
depth
default int depth()Return the current depth. -
isAutoPersistUpdates
boolean isAutoPersistUpdates()Return true if dirty beans are automatically persisted. -
isExplicit
boolean isExplicit()Return true if this transaction was created explicitly viaEbean.beginTransaction(). -
event
TransactionEvent event()Get the object that holds the event details.This information is used maintain the table state, cache and text indexes. On commit the Table modifications this generates is broadcast around the cluster (if you have a cluster).
-
isPersistCascade
boolean isPersistCascade()Whether persistCascade is on for save and delete. -
isBatchThisRequest
boolean isBatchThisRequest()Return true if this request should be batched. Conversely returns false if this request should be executed immediately. -
batchControl
BatchControl batchControl()Return the BatchControl used to batch up persist requests. -
setBatchControl
Set the BatchControl used to batch up persist requests. There should only be one PersistQueue set per transaction. -
persistenceContext
SpiPersistenceContext persistenceContext()Return the persistence context associated with this transaction.You may wish to hold onto this and set it against another transaction later. This is along the lines of 'extended persistence context' behaviour.
-
setPersistenceContext
Set the persistence context to this transaction.This could be considered similar to 'EJB3 Extended Persistence Context'. In that you can get the PersistenceContext from a transaction, hold onto it, and then set it back later to a second transaction. In general there is one PersistenceContext per Transaction. The getPersistenceContext() and setPersistenceContext() enable a developer to reuse a single PersistenceContext with multiple transactions.
-
internalConnection
Connection internalConnection()Return the underlying Connection for internal use.If the connection is made from Transaction and the user code calls that method we can no longer trust the query only status of a Transaction.
-
isSaveAssocManyIntersection
Return true if the manyToMany intersection should be persisted for this particular relationship direction. -
checkBatchEscalationOnCascade
Return true if batch mode got escalated for this request (and associated cascades). -
flushBatchOnCascade
void flushBatchOnCascade()If batch mode was turned on for the request then flush the batch. -
flushBatchOnRollback
void flushBatchOnRollback()If batch was on then effectively clear the batch such that we can handle exceptions and continue. -
translate
Translate the SQLException. -
markNotQueryOnly
void markNotQueryOnly()Mark the transaction explicitly as not being query only. -
checkBatchEscalationOnCollection
void checkBatchEscalationOnCollection()Potentially escalate batch mode on saving or deleting a collection. -
flushBatchOnCollection
void flushBatchOnCollection()Flush batch if we escalated batch mode on saving or deleting a collection. -
addBeanChange
Add a bean change to the change log. -
sendChangeLog
Send the change set to be prepared and then logged. -
setTenantId
Set the current Tenant Id. -
tenantId
Object tenantId()Return the current Tenant Id. -
profileOffset
long profileOffset()Return the offset time from the start of the transaction. -
profileEvent
Check if the event should be added to a profiling transaction. -
setProfileStream
Set the profileStream to catch and time all the events for this transaction. -
profileStream
ProfileStream profileStream()Return the stream that profiling events are written to. -
setProfileLocation
Set the profile location for this transaction. -
profileLocation
ProfileLocation profileLocation()Return the profile location for this transaction. -
isNestedUseSavepoint
boolean isNestedUseSavepoint()Return true when nested transactions should create Savepoints. -
isSkipCacheExplicit
boolean isSkipCacheExplicit()Return true if explicitly set to skip cache (ignores skipOnWrite). -
preCommit
void preCommit()Fire pre commit processing/listeners. -
postCommit
void postCommit()Fire post commit events and listeners. -
postRollback
Fire post rollback events and listeners. -
deactivateExternal
void deactivateExternal()Set the transaction to be inactive via external transaction manager. -
setAutoCommitOnFindIterate
default void setAutoCommitOnFindIterate()Set autocommit to false for a findIterate query.This is done for specific platforms that need it, in order to make use cursors to stream a large or unbounded query result to the client.
-