Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

can we access the database directly from the jira api?

David Lemon May 26, 2013

Hello folks,

Is there any function in the jira api(5.2.11) mend for doing direct updates in the database?

like I have to update the PKEY in thd jiraissue table.

and some changes in changelog table

if yes then how?

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

3 votes
Answer accepted
Mizan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 26, 2013

You cannot update directly like we update using a sql statement . You will need to update through the provided JIRA api. For example if you want to update the issue you will need o use the updateIssue() method

David Lemon May 26, 2013

Hello mizan,

I want to update the pKey of the Issue.. but that function seems to be not working when i am updating the Pkey of the issue.

can you check with your excellience and tell me.

psudocode:

MutableIssue mIssue = (MutableIssue) event.getIssue();

mIssue.setProjectObject(newProjectObject);

mIssue.setPkey(newProjectObject.getKey());

ComponentAccessor.IssueManager.updateIssue(MyUser,mIssue,EventDispatcher,true)

Mizan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 26, 2013

You can set the project for an issue but not the Project Key , project key is a fixed value and cannot be changed .

Do you want to change the project key for a partiular project ? or are you moving an issue to a different project ?

what are you trying to achieve ?

David Lemon May 26, 2013

https://answers.atlassian.com/questions/163857/not-able-to-update-project-object-and-issue-key

see the above question.

i am trying to update issue key.

mIssue.setPkey(newProjectObject.getKey()); is actually

mIssue.setkey(newProjectObject.getKey());

that was by mistake

I am trying to change the issue key and project of my issue

reffer this.

https://answers.atlassian.com/questions/173760/update-function-not-working

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 26, 2013

As explained in several other places Sohil has posted this question, you cannot "edit" an issue when you want to change the project it belongs to, you have to "move" it.

David Lemon May 26, 2013

hello Nic Brough Moving means creating new issue object and assigning it with the old values and deleting the old issue????

is this what you want to say??

2 votes
Harry Chan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 26, 2013

You *can* access the database. It'd be hacky and not portable though. Just get the JNDI resource or direct JDBC access.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 30, 2013

I think you mean you *can* READ the database. Not write to it.

David Lemon June 2, 2013

No i instead Need to write to the database.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 2, 2013

Then this is not the answer you are looking for.

Harry's answer is correct, but only for reading the Jira database internally. You must not update the Jira database except via the internal API. It's no good using the internal database layer to update it, that will break, you must use the API. I can't emphasise this enough - issuing database insert, update or delete statements against any Jira table is likely to break it, and, if you absolutely must do it with SQL, you must have Jira offline, and if you've touched issue data, and possibly other things, re-index afterwards. (Ok, there's a handful of exceptions, but not many)

David Lemon June 16, 2013

Yes Nic i have done it using the data access layer of the jira not firing the actual sql queries but using OfBiz class. That surprisingly worked

TAGS
AUG Leaders

Atlassian Community Events