- All Implemented Interfaces:
Transaction,SpiTransaction,AutoCloseable
- Direct Known Subclasses:
ScopedTransaction
-
Field Summary
FieldsFields inherited from interface io.ebean.Transaction
READ_COMMITTED, READ_UNCOMMITTED, REPEATABLE_READ, SERIALIZABLE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddBeanChange(BeanChange beanChange) Add a bean change to the change log.voidaddModification(String tableName, boolean inserts, boolean updates, boolean deletes) 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.voidvoidSet the transaction to be inactive via external transaction manager.intdepth()Return the current depth.voiddepth(int diff) Modify the current 'depth' of the transaction.voidDecrement the depth BUT only if depth is greater than 0.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.voidflush()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.getUserObject(String name) id()Returns a String used to identify the transaction.Return the underlying Connection for internal use.booleanisActive()booleanReturn true if dirty beans are automatically persisted.booleanbooleanbooleanReturn true if this request should be batched.booleanReturn true if this transaction was created explicitly viaEbean.beginTransaction().booleanbooleanisLogSql()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.booleanbooleanisRegisteredBean(Object bean) Return true if this is a bean that has already been persisted in the current recursive save request.booleanReturn true if this is a bean that has already been saved/deleted.booleanbooleanisSaveAssocManyIntersection(String intersectionTable, String beanName) Return true if the manyToMany intersection should be persisted for this particular relationship direction.booleanbooleanReturn 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.voidputUserObject(String name, Object value) voidregister(TransactionCallback callback) voidRegister a "Deferred Relationship" that requires an additional update later.voidregisterDeleteBean(Integer hash) Add a deleting bean to the registered list.voidsendChangeLog(ChangeSet changes) Send the change set to be prepared and then logged.voidsetAutoPersistUpdates(boolean autoPersistUpdates) voidsetBatchControl(BatchControl control) Set the BatchControl used to batch up persist requests.voidsetBatchMode(boolean useBatch) voidsetBatchOnCascade(boolean batchMode) voidsetBatchSize(int batchSize) voidsetFlushOnMixed(boolean batchFlushOnMixed) voidsetFlushOnQuery(boolean batchFlushOnQuery) voidsetGetGeneratedKeys(boolean getGeneratedKeys) voidvoidvoidsetPersistCascade(boolean persistCascade) 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.voidsetReadOnly(boolean readOnly) voidsetSkipCache(boolean skipCache) voidsetTenantId(Object tenantId) Set the current Tenant Id.voidsetUpdateAllLoadedProperties(boolean updateAllLoaded) longReturn 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 class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.ebean.Transaction
close, commit, end, rollback, rollback, rollbackAndContinue, setRollbackOnly
-
Field Details
-
transaction
-
-
Constructor Details
-
SpiTransactionProxy
public SpiTransactionProxy()
-
-
Method Details
-
translate
Description copied from interface:SpiTransactionTranslate the SQLException.- Specified by:
translatein interfaceSpiTransaction
-
startNanoTime
public long startNanoTime()Description copied from interface:SpiTransactionReturn the start timestamp for the transaction (JVM side).- Specified by:
startNanoTimein interfaceSpiTransaction
-
setLabel
- Specified by:
setLabelin interfaceTransaction
-
label
Description copied from interface:SpiTransactionReturn the user defined label for the transaction.- Specified by:
labelin interfaceSpiTransaction
-
setAutoPersistUpdates
public void setAutoPersistUpdates(boolean autoPersistUpdates) - Specified by:
setAutoPersistUpdatesin interfaceTransaction
-
isAutoPersistUpdates
public boolean isAutoPersistUpdates()Description copied from interface:SpiTransactionReturn true if dirty beans are automatically persisted.- Specified by:
isAutoPersistUpdatesin interfaceSpiTransaction
-
commitAndContinue
public void commitAndContinue()- Specified by:
commitAndContinuein interfaceTransaction
-
isRollbackOnly
public boolean isRollbackOnly()- Specified by:
isRollbackOnlyin interfaceTransaction
-
setNestedUseSavepoint
public void setNestedUseSavepoint()- Specified by:
setNestedUseSavepointin interfaceTransaction
-
isNestedUseSavepoint
public boolean isNestedUseSavepoint()Description copied from interface:SpiTransactionReturn true when nested transactions should create Savepoints.- Specified by:
isNestedUseSavepointin interfaceSpiTransaction
-
profileOffset
public long profileOffset()Description copied from interface:SpiTransactionReturn the offset time from the start of the transaction.- Specified by:
profileOffsetin interfaceSpiTransaction
-
profileEvent
Description copied from interface:SpiTransactionCheck if the event should be added to a profiling transaction.- Specified by:
profileEventin interfaceSpiTransaction
-
setProfileStream
Description copied from interface:SpiTransactionSet the profileStream to catch and time all the events for this transaction.- Specified by:
setProfileStreamin interfaceSpiTransaction
-
profileStream
Description copied from interface:SpiTransactionReturn the stream that profiling events are written to.- Specified by:
profileStreamin interfaceSpiTransaction
-
setProfileLocation
Description copied from interface:SpiTransactionSet the profile location for this transaction.- Specified by:
setProfileLocationin interfaceSpiTransaction
-
profileLocation
Description copied from interface:SpiTransactionReturn the profile location for this transaction.- Specified by:
profileLocationin interfaceSpiTransaction
-
setTenantId
Description copied from interface:SpiTransactionSet the current Tenant Id.- Specified by:
setTenantIdin interfaceSpiTransaction
-
tenantId
Description copied from interface:SpiTransactionReturn the current Tenant Id.- Specified by:
tenantIdin interfaceSpiTransaction
-
isLogSql
public boolean isLogSql()Description copied from interface:SpiTransactionReturn true if generated SQL and Bind values should be logged to the transaction log.- Specified by:
isLogSqlin interfaceSpiTransaction
-
isLogSummary
public boolean isLogSummary()Description copied from interface:SpiTransactionReturn true if summary level events should be logged to the transaction log.- Specified by:
isLogSummaryin interfaceSpiTransaction
-
logSql
Description copied from interface:SpiTransactionLog a message to the SQL logger.- Specified by:
logSqlin interfaceSpiTransaction
-
logSummary
Description copied from interface:SpiTransactionLog a summary message to the SUMMARY logger.- Specified by:
logSummaryin interfaceSpiTransaction
-
logTxn
Description copied from interface:SpiTransactionLog a transaction message to the transaction logger.- Specified by:
logTxnin interfaceSpiTransaction
-
setSkipCache
public void setSkipCache(boolean skipCache) - Specified by:
setSkipCachein interfaceTransaction
-
isSkipCacheExplicit
public boolean isSkipCacheExplicit()Description copied from interface:SpiTransactionReturn true if explicitly set to skip cache (ignores skipOnWrite).- Specified by:
isSkipCacheExplicitin interfaceSpiTransaction
-
isSkipCache
public boolean isSkipCache()- Specified by:
isSkipCachein interfaceTransaction
-
addBeanChange
Description copied from interface:SpiTransactionAdd a bean change to the change log.- Specified by:
addBeanChangein interfaceSpiTransaction
-
sendChangeLog
Description copied from interface:SpiTransactionSend the change set to be prepared and then logged.- Specified by:
sendChangeLogin interfaceSpiTransaction
-
registerDeferred
Description copied from interface:SpiTransactionRegister a "Deferred Relationship" that requires an additional update later.- Specified by:
registerDeferredin interfaceSpiTransaction
-
registerDeleteBean
Description copied from interface:SpiTransactionAdd a deleting bean to the registered list.This is to handle bi-directional relationships where both sides Cascade.
- Specified by:
registerDeleteBeanin interfaceSpiTransaction
-
isRegisteredDeleteBean
Description copied from interface:SpiTransactionReturn true if this is a bean that has already been saved/deleted.- Specified by:
isRegisteredDeleteBeanin interfaceSpiTransaction
-
unregisterBeans
public void unregisterBeans()Description copied from interface:SpiTransactionUnregister the persisted beans. Expected after persisting top level beans and hence including all beans that were cascade persisted.- Specified by:
unregisterBeansin interfaceSpiTransaction
-
isRegisteredBean
Description copied from interface:SpiTransactionReturn 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.
- Specified by:
isRegisteredBeanin interfaceSpiTransaction
-
id
Description copied from interface:SpiTransactionReturns a String used to identify the transaction. This id is used for Transaction logging.- Specified by:
idin interfaceSpiTransaction
-
register
- Specified by:
registerin interfaceTransaction
-
isReadOnly
public boolean isReadOnly()- Specified by:
isReadOnlyin interfaceTransaction
-
setReadOnly
public void setReadOnly(boolean readOnly) - Specified by:
setReadOnlyin interfaceTransaction
-
isActive
public boolean isActive()- Specified by:
isActivein interfaceTransaction
-
setPersistCascade
public void setPersistCascade(boolean persistCascade) - Specified by:
setPersistCascadein interfaceTransaction
-
setUpdateAllLoadedProperties
public void setUpdateAllLoadedProperties(boolean updateAllLoaded) - Specified by:
setUpdateAllLoadedPropertiesin interfaceTransaction
-
isUpdateAllLoadedProperties
Description copied from interface:SpiTransactionReturn true if this transaction has updateAllLoadedProperties set. If null is returned the server default is used (set on DatabaseConfig).- Specified by:
isUpdateAllLoadedPropertiesin interfaceSpiTransaction
-
setBatchMode
public void setBatchMode(boolean useBatch) - Specified by:
setBatchModein interfaceTransaction
-
isBatchMode
public boolean isBatchMode()- Specified by:
isBatchModein interfaceTransaction
-
setBatchOnCascade
public void setBatchOnCascade(boolean batchMode) - Specified by:
setBatchOnCascadein interfaceTransaction
-
isBatchOnCascade
public boolean isBatchOnCascade()- Specified by:
isBatchOnCascadein interfaceTransaction
-
setBatchSize
public void setBatchSize(int batchSize) - Specified by:
setBatchSizein interfaceTransaction
-
getBatchSize
public int getBatchSize()Description copied from interface:SpiTransactionReturn the batchSize specifically set for this transaction or 0.Returning 0 implies to use the system wide default batch size.
- Specified by:
getBatchSizein interfaceSpiTransaction- Specified by:
getBatchSizein interfaceTransaction
-
setGetGeneratedKeys
public void setGetGeneratedKeys(boolean getGeneratedKeys) - Specified by:
setGetGeneratedKeysin interfaceTransaction
-
getBatchGetGeneratedKeys
Description copied from interface:SpiTransactionReturn the getGeneratedKeys setting for this transaction.- Specified by:
getBatchGetGeneratedKeysin interfaceSpiTransaction
-
setFlushOnMixed
public void setFlushOnMixed(boolean batchFlushOnMixed) - Specified by:
setFlushOnMixedin interfaceTransaction
-
setFlushOnQuery
public void setFlushOnQuery(boolean batchFlushOnQuery) - Specified by:
setFlushOnQueryin interfaceTransaction
-
isFlushOnQuery
public boolean isFlushOnQuery()- Specified by:
isFlushOnQueryin interfaceTransaction
-
flush
public void flush() throws jakarta.persistence.PersistenceException- Specified by:
flushin interfaceTransaction- Throws:
jakarta.persistence.PersistenceException
-
connection
- Specified by:
connectionin interfaceTransaction
-
addModification
- Specified by:
addModificationin interfaceTransaction
-
putUserObject
- Specified by:
putUserObjectin interfaceTransaction
-
getUserObject
- Specified by:
getUserObjectin interfaceTransaction
-
depth
public void depth(int diff) Description copied from interface:SpiTransactionModify 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.
- Specified by:
depthin interfaceSpiTransaction
-
depthDecrement
public void depthDecrement()Description copied from interface:SpiTransactionDecrement the depth BUT only if depth is greater than 0. Return the amount that depth should be incremented by (0 or 1).- Specified by:
depthDecrementin interfaceSpiTransaction
-
depthReset
public void depthReset()Description copied from interface:SpiTransactionReset the depth back to 0 - done at the end of top level insert and update.- Specified by:
depthResetin interfaceSpiTransaction
-
depth
public int depth()Description copied from interface:SpiTransactionReturn the current depth.- Specified by:
depthin interfaceSpiTransaction
-
isExplicit
public boolean isExplicit()Description copied from interface:SpiTransactionReturn true if this transaction was created explicitly viaEbean.beginTransaction().- Specified by:
isExplicitin interfaceSpiTransaction
-
event
Description copied from interface:SpiTransactionGet 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).
- Specified by:
eventin interfaceSpiTransaction
-
isPersistCascade
public boolean isPersistCascade()Description copied from interface:SpiTransactionWhether persistCascade is on for save and delete.- Specified by:
isPersistCascadein interfaceSpiTransaction
-
isBatchThisRequest
public boolean isBatchThisRequest()Description copied from interface:SpiTransactionReturn true if this request should be batched. Conversely returns false if this request should be executed immediately.- Specified by:
isBatchThisRequestin interfaceSpiTransaction
-
batchControl
Description copied from interface:SpiTransactionReturn the BatchControl used to batch up persist requests.- Specified by:
batchControlin interfaceSpiTransaction
-
setBatchControl
Description copied from interface:SpiTransactionSet the BatchControl used to batch up persist requests. There should only be one PersistQueue set per transaction.- Specified by:
setBatchControlin interfaceSpiTransaction
-
persistenceContext
Description copied from interface:SpiTransactionReturn 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.
- Specified by:
persistenceContextin interfaceSpiTransaction
-
setPersistenceContext
Description copied from interface:SpiTransactionSet 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.
- Specified by:
setPersistenceContextin interfaceSpiTransaction
-
internalConnection
Description copied from interface:SpiTransactionReturn 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.
- Specified by:
internalConnectionin interfaceSpiTransaction
-
isSaveAssocManyIntersection
Description copied from interface:SpiTransactionReturn true if the manyToMany intersection should be persisted for this particular relationship direction.- Specified by:
isSaveAssocManyIntersectionin interfaceSpiTransaction
-
checkBatchEscalationOnCascade
Description copied from interface:SpiTransactionReturn true if batch mode got escalated for this request (and associated cascades).- Specified by:
checkBatchEscalationOnCascadein interfaceSpiTransaction
-
flushBatchOnCascade
public void flushBatchOnCascade()Description copied from interface:SpiTransactionIf batch mode was turned on for the request then flush the batch.- Specified by:
flushBatchOnCascadein interfaceSpiTransaction
-
flushBatchOnRollback
public void flushBatchOnRollback()Description copied from interface:SpiTransactionIf batch was on then effectively clear the batch such that we can handle exceptions and continue.- Specified by:
flushBatchOnRollbackin interfaceSpiTransaction
-
markNotQueryOnly
public void markNotQueryOnly()Description copied from interface:SpiTransactionMark the transaction explicitly as not being query only.- Specified by:
markNotQueryOnlyin interfaceSpiTransaction
-
checkBatchEscalationOnCollection
public void checkBatchEscalationOnCollection()Description copied from interface:SpiTransactionPotentially escalate batch mode on saving or deleting a collection.- Specified by:
checkBatchEscalationOnCollectionin interfaceSpiTransaction
-
flushBatchOnCollection
public void flushBatchOnCollection()Description copied from interface:SpiTransactionFlush batch if we escalated batch mode on saving or deleting a collection.- Specified by:
flushBatchOnCollectionin interfaceSpiTransaction
-
preCommit
public void preCommit()Description copied from interface:SpiTransactionFire pre commit processing/listeners.- Specified by:
preCommitin interfaceSpiTransaction
-
postCommit
public void postCommit()Description copied from interface:SpiTransactionFire post commit events and listeners.- Specified by:
postCommitin interfaceSpiTransaction
-
postRollback
Description copied from interface:SpiTransactionFire post rollback events and listeners.- Specified by:
postRollbackin interfaceSpiTransaction
-
deactivateExternal
public void deactivateExternal()Description copied from interface:SpiTransactionSet the transaction to be inactive via external transaction manager.- Specified by:
deactivateExternalin interfaceSpiTransaction
-