Help with Transaction Support and ActiveObjects in Jira Server

Hi everyone,

I’m trying to build a Jira Server plugin.

I want to insert list of records in a database table which resides in Jira database. However I need to insert N records and do some other stuff in the same transaction. Basically, I want inserted records to be rolled back if any error occurs.

activeObjects.executeInTransaction(new TransactionCallback<Void>() {
	@Override
	public Void doInTransaction() {
		activeObjects.create(Employee.class, new DBParam("EMPLOYEE_ID", "1"));
		activeObjects.create(Employee.class, new DBParam("EMPLOYEE_ID", "2"));
		activeObjects.create(Employee.class, new DBParam("EMPLOYEE_ID", "3"));
		int i = Integer.valueOf("e");
		return null;
	}
});

As far as I see from the following links Jira does not support transactions. Also I built a simple refapp plugin and run it against to first JIRA and later then to Confluence. Confluence rollbacks if your class/method has @Transactional annotation. JIRA, unfortunately, does not.

  1. No transactions in JIRA so this is effectively a NoOp.

  2. Enable ActiveObjects transaction support in JIRA

Is there any other way to do what I want in JIRA server? I can also move my tables to an external database, they do not have to stay with JIRA tables. I just want these db and other operations to be executed in same transaction.

Sorry, I know this has been asked many times but I couldn’t find any other way to achieve this. I can provide my code if its needed.

Thank you for your help,
Kind Regards

3 Likes

Just like you already know - JIRA doesn’t support Transactions. If that ever changes it would be in a major version(8.x or 9.x) since it could impact a lot of Addons.

My suggestion would be to emulate it and basically check each database calls as you progress(perhaps a staging table?). Not ideal but it is what we have.

2 Likes

I cannot believe what I am reading.

Thank GOD Andrei provided a workaround as I was about to jump out the window: https://jira.atlassian.com/browse/JRASERVER-25808?focusedCommentId=1742394&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-1742394