- All Implemented Interfaces:
Transaction,SpiTransaction,TxnProfileEventCodes,AutoCloseable
-
Field Summary
Fields inherited from interface io.ebean.Transaction
READ_COMMITTED, READ_UNCOMMITTED, REPEATABLE_READ, SERIALIZABLEFields inherited from interface io.ebeaninternal.api.TxnProfileEventCodes
EVT_CALLABLESQL, EVT_COMMIT, EVT_DELETE, EVT_DELETE_PERMANENT, EVT_DELETE_SOFT, EVT_INSERT, EVT_ORMUPDATE, EVT_ROLLBACK, EVT_UPDATE, EVT_UPDATESQL, FIND_ATTRIBUTE, FIND_ATTRIBUTE_SET, FIND_COUNT, FIND_DELETE, FIND_EXISTS, FIND_ID_LIST, FIND_ITERATE, FIND_MANY, FIND_MANY_LAZY, FIND_ONE, FIND_ONE_LAZY, FIND_SUBQUERY, FIND_UPDATE -
Constructor Summary
ConstructorsConstructorDescriptionJtaTransaction(boolean explicit, jakarta.transaction.UserTransaction utx, DataSource ds, TransactionManager manager) Create the JtaTransaction. -
Method Summary
Modifier and TypeMethodDescriptionfinal voidaddBeanChange(BeanChange beanChange) Add a bean change to the change log.final voidaddModification(String tableName, boolean inserts, boolean updates, boolean deletes) final BatchControlReturn the BatchControl used to batch up persist requests.final booleancheckBatchEscalationOnCascade(PersistRequestBean<?> request) Return true if batch mode got escalated for this request (and associated cascades).final voidPotentially escalate batch mode on saving or deleting a collection.final voidclose()Alias for end(), which enables this class to be used in try-with-resources.voidcommit()Commit the transaction.voidPerform a commit, fire callbacks and notify l2 cache etc.Return the underlying connection for public use.voidSet the transaction to be inactive via external transaction manager.final intdepth()Return the current depth.final voiddepth(int diff) Modify the current 'depth' of the transaction.final voidDecrement the depth BUT only if depth is greater than 0.final voidReset the depth back to 0 - done at the end of top level insert and update.voidend()If the transaction is active then perform rollback.final TransactionEventevent()Return the underlying TransactionEvent.final voidflush()Flush any queued persist requests.final voidFlush after completing persist cascade.final voidFlush batch if we escalated batch mode on saving or deleting a collection.final voidIf batch was on then effectively clear the batch such that we can handle exceptions and continue.final BooleanReturn the getGeneratedKeys setting for this transaction.final intReturn the batchSize specifically set for this transaction or 0.final ObjectgetUserObject(String name) final Stringid()Return the transaction id.Return the underlying connection for internal use.booleanisActive()Return true if the transaction is active.final booleanReturn true if dirty beans are automatically persisted.final booleanfinal booleanfinal booleanReturn true if this request should be batched.final booleanReturn true if this was an explicitly created transaction.final booleanfinal booleanisLogSql()Return true if generated SQL and Bind values should be logged to the transaction log.final booleanReturn true if summary level events should be logged to the transaction log.final booleanReturn true when nested transactions should create Savepoints.final booleanWhether persistCascade is on for save and delete.booleanfinal booleanisRegisteredBean(Object bean) Return true if this is a bean that has already been saved.final booleanisRegisteredDeleteBean(Integer persistingBean) Return true if this is a bean that has already been saved/deleted.final booleanReturn true if the transaction is marked as rollback only.final booleanisSaveAssocManyIntersection(String intersectionTable, String beanName) Return true if the m2m intersection save is allowed from a given bean direction.final booleanfinal booleanReturn true if explicitly set to skip cache (ignores skipOnWrite).final BooleanReturn true if this transaction has updateAllLoadedProperties set.final Stringlabel()Return the user defined label for the transaction.voidLog a message to the SQL logger.final voidlogSummary(String msg, Object... args) Log a summary message to the SUMMARY logger.voidLog a transaction message to the transaction logger.final voidMark the transaction explicitly as not being query only.final SpiPersistenceContextReturn the persistence context associated with this transaction.final voidFire post commit events and listeners.final voidpostRollback(Throwable cause) Fire post rollback events and listeners.final voidFire pre commit processing/listeners.final voidCheck if the event should be added to a profiling transaction.final ProfileLocationReturn the profile location for this transaction.final longReturn the offset time from the start of the transaction.final ProfileStreamReturn the stream that profiling events are written to.final voidputUserObject(String name, Object value) final voidregister(TransactionCallback callback) final voidRegister a "Deferred Relationship" that requires an additional update later.final voidregisterDeleteBean(Integer persistingBean) Add a bean to the registed list.voidrollback()Rollback the transaction.voidRollback the transaction.voidfinal voidsendChangeLog(ChangeSet changesRequest) Send the change set to be prepared and then logged.final voidsetAutoPersistUpdates(boolean autoPersistUpdates) final voidsetBatchControl(BatchControl batchControl) Set the BatchControl to the transaction.final voidsetBatchMode(boolean batchMode) final voidsetBatchOnCascade(boolean batchMode) final voidsetBatchSize(int batchSize) final voidsetFlushOnMixed(boolean batchFlushOnMixed) final voidsetFlushOnQuery(boolean batchFlushOnQuery) final voidsetGetGeneratedKeys(boolean getGeneratedKeys) final voidfinal voidfinal voidsetPersistCascade(boolean persistCascade) final voidSet the persistence context to this transaction.final voidsetProfileLocation(ProfileLocation profileLocation) Set the profile location for this transaction.final voidsetProfileStream(ProfileStream profileStream) Set the profileStream to catch and time all the events for this transaction.voidsetReadOnly(boolean readOnly) final voidMark the transaction as rollback only.final voidsetSkipCache(boolean skipCache) final voidsetTenantId(Object tenantId) Set the current Tenant Id.final voidsetUpdateAllLoadedProperties(boolean updateAllLoadedProperties) final longReturn the start timestamp for the transaction (JVM side).final ObjecttenantId()Return the current Tenant Id.toString()final jakarta.persistence.PersistenceExceptiontranslate(String message, SQLException cause) Translate the SQLException.final voidUnregister the persisted beans (when persisting at the top level).
-
Constructor Details
-
JtaTransaction
public JtaTransaction(boolean explicit, jakarta.transaction.UserTransaction utx, DataSource ds, TransactionManager manager) Create the JtaTransaction.
-
-
Method Details
-
commit
public void commit()Commit the transaction.- Specified by:
commitin interfaceTransaction
-
rollback
public void rollback()Rollback the transaction.- Specified by:
rollbackin interfaceTransaction
-
rollback
Rollback the transaction.- Specified by:
rollbackin interfaceTransaction
-
setLabel
- Specified by:
setLabelin interfaceTransaction
-
label
Description copied from interface:SpiTransactionReturn the user defined label for the transaction.- Specified by:
labelin interfaceSpiTransaction
-
startNanoTime
public final long startNanoTime()Description copied from interface:SpiTransactionReturn the start timestamp for the transaction (JVM side).- Specified by:
startNanoTimein interfaceSpiTransaction
-
profileOffset
public final 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
-
setAutoPersistUpdates
public final void setAutoPersistUpdates(boolean autoPersistUpdates) - Specified by:
setAutoPersistUpdatesin interfaceTransaction
-
isAutoPersistUpdates
public final boolean isAutoPersistUpdates()Description copied from interface:SpiTransactionReturn true if dirty beans are automatically persisted.- Specified by:
isAutoPersistUpdatesin interfaceSpiTransaction
-
isSkipCacheExplicit
public final boolean isSkipCacheExplicit()Description copied from interface:SpiTransactionReturn true if explicitly set to skip cache (ignores skipOnWrite).- Specified by:
isSkipCacheExplicitin interfaceSpiTransaction
-
isSkipCache
public final boolean isSkipCache()- Specified by:
isSkipCachein interfaceTransaction
-
setSkipCache
public final void setSkipCache(boolean skipCache) - Specified by:
setSkipCachein interfaceTransaction
-
toString
-
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
-
register
- Specified by:
registerin interfaceTransaction
-
registerDeferred
Description copied from interface:SpiTransactionRegister a "Deferred Relationship" that requires an additional update later.- Specified by:
registerDeferredin interfaceSpiTransaction
-
registerDeleteBean
Add a bean to the registed list.This is to handle bi-directional relationships where both sides Cascade.
- Specified by:
registerDeleteBeanin interfaceSpiTransaction
-
isRegisteredDeleteBean
Return true if this is a bean that has already been saved/deleted.- Specified by:
isRegisteredDeleteBeanin interfaceSpiTransaction
-
unregisterBeans
public final void unregisterBeans()Unregister the persisted beans (when persisting at the top level).- Specified by:
unregisterBeansin interfaceSpiTransaction
-
isRegisteredBean
Return true if this is a bean that has already been saved. This will register the bean if it is not already.- Specified by:
isRegisteredBeanin interfaceSpiTransaction
-
isSaveAssocManyIntersection
Return true if the m2m intersection save is allowed from a given bean direction. This is to stop m2m intersection management via both directions of a m2m.- Specified by:
isSaveAssocManyIntersectionin interfaceSpiTransaction
-
depth
public final 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
-
depth
public final int depth()Description copied from interface:SpiTransactionReturn the current depth.- Specified by:
depthin interfaceSpiTransaction
-
depthDecrement
public final 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 final 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
-
markNotQueryOnly
public final void markNotQueryOnly()Description copied from interface:SpiTransactionMark the transaction explicitly as not being query only.- Specified by:
markNotQueryOnlyin interfaceSpiTransaction
-
isReadOnly
public boolean isReadOnly()- Specified by:
isReadOnlyin interfaceTransaction
-
setReadOnly
public void setReadOnly(boolean readOnly) - Specified by:
setReadOnlyin interfaceTransaction
-
setUpdateAllLoadedProperties
public final void setUpdateAllLoadedProperties(boolean updateAllLoadedProperties) - 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 final void setBatchMode(boolean batchMode) - Specified by:
setBatchModein interfaceTransaction
-
isBatchMode
public final boolean isBatchMode()- Specified by:
isBatchModein interfaceTransaction
-
setBatchOnCascade
public final void setBatchOnCascade(boolean batchMode) - Specified by:
setBatchOnCascadein interfaceTransaction
-
isBatchOnCascade
public final boolean isBatchOnCascade()- Specified by:
isBatchOnCascadein interfaceTransaction
-
getBatchGetGeneratedKeys
Description copied from interface:SpiTransactionReturn the getGeneratedKeys setting for this transaction.- Specified by:
getBatchGetGeneratedKeysin interfaceSpiTransaction
-
setGetGeneratedKeys
public final void setGetGeneratedKeys(boolean getGeneratedKeys) - Specified by:
setGetGeneratedKeysin interfaceTransaction
-
setFlushOnMixed
public final void setFlushOnMixed(boolean batchFlushOnMixed) - Specified by:
setFlushOnMixedin interfaceTransaction
-
getBatchSize
public final 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 interfaceSpiTransaction- Specified by:
getBatchSizein interfaceTransaction
-
setBatchSize
public final void setBatchSize(int batchSize) - Specified by:
setBatchSizein interfaceTransaction
-
isFlushOnQuery
public final boolean isFlushOnQuery()- Specified by:
isFlushOnQueryin interfaceTransaction
-
setFlushOnQuery
public final void setFlushOnQuery(boolean batchFlushOnQuery) - Specified by:
setFlushOnQueryin interfaceTransaction
-
isBatchThisRequest
public final boolean isBatchThisRequest()Return true if this request should be batched. Returning false means that this request should be executed immediately.- Specified by:
isBatchThisRequestin interfaceSpiTransaction
-
checkBatchEscalationOnCollection
public final void checkBatchEscalationOnCollection()Description copied from interface:SpiTransactionPotentially escalate batch mode on saving or deleting a collection.- Specified by:
checkBatchEscalationOnCollectionin interfaceSpiTransaction
-
flushBatchOnCollection
public final void flushBatchOnCollection()Description copied from interface:SpiTransactionFlush batch if we escalated batch mode on saving or deleting a collection.- Specified by:
flushBatchOnCollectionin interfaceSpiTransaction
-
translate
Description copied from interface:SpiTransactionTranslate the SQLException.- Specified by:
translatein interfaceSpiTransaction
-
flushBatchOnCascade
public final void flushBatchOnCascade()Flush after completing persist cascade.- Specified by:
flushBatchOnCascadein interfaceSpiTransaction
-
flushBatchOnRollback
public final 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
-
checkBatchEscalationOnCascade
Description copied from interface:SpiTransactionReturn true if batch mode got escalated for this request (and associated cascades).- Specified by:
checkBatchEscalationOnCascadein interfaceSpiTransaction
-
batchControl
Description copied from interface:SpiTransactionReturn the BatchControl used to batch up persist requests.- Specified by:
batchControlin interfaceSpiTransaction
-
setBatchControl
Set the BatchControl to the transaction. This is done once per transaction on the first persist request.- Specified by:
setBatchControlin interfaceSpiTransaction
-
flush
public final void flush()Flush any queued persist requests.This is general will result in a number of batched PreparedStatements executing.
- Specified by:
flushin interfaceTransaction
-
persistenceContext
Return the persistence context associated with this transaction.- Specified by:
persistenceContextin interfaceSpiTransaction
-
setPersistenceContext
Set the persistence context to this transaction.This could be considered similar to EJB3 Extended PersistanceContext. In that you get the PersistanceContext from a transaction, hold onto it, and then set it back later to a second transaction.
- Specified by:
setPersistenceContextin interfaceSpiTransaction
-
event
Return the underlying TransactionEvent.- Specified by:
eventin interfaceSpiTransaction
-
isExplicit
public final boolean isExplicit()Return true if this was an explicitly created transaction.- Specified by:
isExplicitin interfaceSpiTransaction
-
isLogSql
public final 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 final 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
-
id
Return the transaction id.- Specified by:
idin 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
-
internalConnection
Return the underlying connection for internal use.- Specified by:
internalConnectionin interfaceSpiTransaction
-
connection
Return the underlying connection for public use.- Specified by:
connectionin interfaceTransaction
-
postCommit
public final void postCommit()Description copied from interface:SpiTransactionFire post commit events and listeners.- Specified by:
postCommitin interfaceSpiTransaction
-
preCommit
public final void preCommit()Description copied from interface:SpiTransactionFire pre commit processing/listeners.- Specified by:
preCommitin interfaceSpiTransaction
-
commitAndContinue
public void commitAndContinue()Perform a commit, fire callbacks and notify l2 cache etc.This leaves the transaction active and expects another commit to occur later (which closes the underlying connection etc).
- Specified by:
commitAndContinuein interfaceTransaction
-
isRollbackOnly
public final boolean isRollbackOnly()Return true if the transaction is marked as rollback only.- Specified by:
isRollbackOnlyin interfaceTransaction
-
setRollbackOnly
public final void setRollbackOnly()Mark the transaction as rollback only.- Specified by:
setRollbackOnlyin interfaceTransaction
-
isNestedUseSavepoint
public final boolean isNestedUseSavepoint()Description copied from interface:SpiTransactionReturn true when nested transactions should create Savepoints.- Specified by:
isNestedUseSavepointin interfaceSpiTransaction
-
setNestedUseSavepoint
public final void setNestedUseSavepoint()- Specified by:
setNestedUseSavepointin interfaceTransaction
-
rollbackAndContinue
public void rollbackAndContinue()- Specified by:
rollbackAndContinuein interfaceTransaction
-
postRollback
Description copied from interface:SpiTransactionFire post rollback events and listeners.- Specified by:
postRollbackin interfaceSpiTransaction
-
end
public void end() throws jakarta.persistence.PersistenceExceptionIf the transaction is active then perform rollback.- Specified by:
endin interfaceTransaction- Throws:
jakarta.persistence.PersistenceException
-
isActive
public boolean isActive()Return true if the transaction is active.- Specified by:
isActivein interfaceTransaction
-
deactivateExternal
public void deactivateExternal()Description copied from interface:SpiTransactionSet the transaction to be inactive via external transaction manager.- Specified by:
deactivateExternalin interfaceSpiTransaction
-
isPersistCascade
public final boolean isPersistCascade()Description copied from interface:SpiTransactionWhether persistCascade is on for save and delete.- Specified by:
isPersistCascadein interfaceSpiTransaction
-
setPersistCascade
public final void setPersistCascade(boolean persistCascade) - Specified by:
setPersistCascadein interfaceTransaction
-
addModification
public final void addModification(String tableName, boolean inserts, boolean updates, boolean deletes) - Specified by:
addModificationin interfaceTransaction
-
putUserObject
- Specified by:
putUserObjectin interfaceTransaction
-
getUserObject
- Specified by:
getUserObjectin interfaceTransaction
-
close
public final void close()Alias for end(), which enables this class to be used in try-with-resources.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceTransaction
-