Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Create and use custom transaction management in JIRA

Saurabh Gupta
Contributor
April 9, 2018

As mentioned in this ticket -
https://jira.atlassian.com/browse/JRASERVER-25808

The workaround for using transactions with ActiveObjects in Jira (and what Atlassian is doing) would be to manually start a transaction:

import com.atlassian.jira.transaction.Transaction;
import com.atlassian.jira.transaction.Txn;


    Transaction txn = Txn.begin();
    try {
        ...
        txn.commit();
        ...
    } finally {
        txn.finallyRollbackIfNotCommitted();
    }

 

begin is declared as

/**
 * Represents the ability to peform a database transaction in JIRA.
 *
 * @since v4.4.1
 */
public interface TransactionSupport {
    /**
     * This begins a new transaction if one is not already running for this thread.
     * <p>
     * It will be a NoOp if a transaction is already running and in this case a call to {@link
     * Transaction#commit()} will also be a NoOp.  The outer caller is then reponsible
     * for the ultimate commit or rollback.
     * <p>
     * It will also be a NoOp if a transaction support in JIRA is turned off.
     *
     * @return a {@link Transaction} context object that you can called commit or rollback on
     * @throws TransactionRuntimeException if the transaction can not be established at all
     */
    Transaction begin() throws TransactionRuntimeException;
}
 

So to interact with Transaction interface, I need it reference the appropriate maven dependency.  Where can I get the dependency? I am developing the plugin for JIRA 7.3.0.

1 answer

0 votes
Saurabh Gupta
Contributor
April 11, 2018

Asked this question at wrong place, moved this to Atlassian developer community.

Heres the link if anyone wants -

https://community.developer.atlassian.com/t/create-and-use-custom-transaction-management-in-jira/17265

Suggest an answer

Log in or Sign up to answer